Skip to content

Commit

Permalink
Move the code from lib.rs to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
gentoo90 committed Feb 17, 2023
1 parent 17378a9 commit c3ac5ba
Show file tree
Hide file tree
Showing 8 changed files with 1,049 additions and 1,014 deletions.
26 changes: 26 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2023, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
#![macro_use]
use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use std::slice;

macro_rules! werr {
($e:expr) => {
Err(io::Error::from_raw_os_error($e as i32))
};
}

pub(crate) fn to_utf16<P: AsRef<OsStr>>(s: P) -> Vec<u16> {
s.as_ref()
.encode_wide()
.chain(Some(0).into_iter())
.collect()
}

pub(crate) fn v16_to_v8(v: &[u16]) -> Vec<u8> {
unsafe { slice::from_raw_parts(v.as_ptr() as *const u8, v.len() * 2).to_vec() }
}
2 changes: 1 addition & 1 deletion src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// may not be copied, modified, or distributed
// except according to those terms.
use crate::enums::*;
use crate::RegKey;
use crate::reg_key::RegKey;
use std::error::Error;
use std::fmt;
use std::io;
Expand Down
2 changes: 1 addition & 1 deletion src/encoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// except according to those terms.
use self::EncoderState::*;
use crate::enums::*;
use crate::reg_key::RegKey;
use crate::transaction::Transaction;
use crate::RegKey;
use std::error::Error;
use std::fmt;
use std::io;
Expand Down
Loading

0 comments on commit c3ac5ba

Please sign in to comment.