Skip to content

Commit 6d6f35b

Browse files
committed
Merge branch 'winapi'. Bump version to 0.53.0
2 parents 1c56127 + cb06180 commit 6d6f35b

16 files changed

+158
-50
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,18 @@ jobs:
119119
with:
120120
command: update
121121
args: --package windows_x86_64_msvc:0.48.5 --precise 0.48.5
122+
- name: Restrict libc version
123+
if: matrix.restrict_deps_versions
124+
uses: actions-rs/cargo@v1
125+
with:
126+
command: update
127+
args: --package libc --precise 0.2.164
128+
- name: Restrict num-traits version
129+
if: matrix.restrict_deps_versions
130+
uses: actions-rs/cargo@v1
131+
with:
132+
command: update
133+
args: --package num-traits --precise 0.2.18
122134
- name: Check formatting
123135
if: matrix.lint
124136
uses: actions-rs/cargo@v1

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.15.0, 0.53.0
4+
* Don't stop deserialization of `Any` due to `REG_NONE` (pullrequest [#67](https://github.com/gentoo90/winreg-rs/pull/67), fixes [#66](https://github.com/gentoo90/winreg-rs/issues/66))
5+
* Implement (de)serialization of `Option` ([#56](https://github.com/gentoo90/winreg-rs/issues/56))
6+
* Add `RegKey` methods for creating/opening subkeys with custom options ([#65](https://github.com/gentoo90/winreg-rs/pull/65))
7+
38
## 0.52.0
49
* Breaking change: `.commit()` and `.rollback()` now consume the transaction ([#62](https://github.com/gentoo90/winreg-rs/issues/62))
510
* Add `RegKey::rename_subkey()` method ([#58](https://github.com/gentoo90/winreg-rs/issues/58))

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "winreg"
33
edition = "2018"
4-
version = "0.52.0"
4+
version = "0.53.0"
55
authors = ["Igor Shaula <[email protected]>"]
66
license = "MIT"
77
description = "Rust bindings to MS Windows Registry API"
@@ -13,7 +13,7 @@ categories = ["api-bindings", "os::windows-apis"]
1313

1414
[dependencies]
1515
cfg-if = "1.0"
16-
windows-sys = {version = "0.48.0", features = [
16+
windows-sys = {version = "0.48", features = [
1717
"Win32_Foundation",
1818
"Win32_System_Time",
1919
"Win32_System_Registry",

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Current features:
2727
* `u64` <=> `REG_QWORD`
2828
* Iteration through key names and through values
2929
* Transactions
30-
* Transacted serialization of rust types into/from registry (only primitives, structures and maps for now)
30+
* Transacted serialization of rust types into/from registry (only primitives, `Option`s, structures and maps for now)
3131

3232
## Usage
3333

@@ -36,7 +36,7 @@ Current features:
3636
```toml
3737
# Cargo.toml
3838
[dependencies]
39-
winreg = "0.52"
39+
winreg = "0.53"
4040
```
4141

4242
```rust
@@ -138,7 +138,7 @@ fn main() -> io::Result<()> {
138138
```toml
139139
# Cargo.toml
140140
[dependencies]
141-
winreg = { version = "0.52", features = ["transactions"] }
141+
winreg = { version = "0.53", features = ["transactions"] }
142142
```
143143

144144
```rust
@@ -179,7 +179,7 @@ fn main() -> io::Result<()> {
179179
```toml
180180
# Cargo.toml
181181
[dependencies]
182-
winreg = { version = "0.52", features = ["serialization-serde"] }
182+
winreg = { version = "0.53", features = ["serialization-serde"] }
183183
serde = "1"
184184
serde_derive = "1"
185185
```
@@ -204,7 +204,7 @@ struct Size {
204204

205205
#[derive(Debug, Serialize, Deserialize, PartialEq)]
206206
struct Rectangle {
207-
coords: Coords,
207+
coords: Option<Coords>,
208208
size: Size,
209209
}
210210

@@ -219,6 +219,7 @@ struct Test {
219219
t_struct: Rectangle,
220220
t_map: HashMap<String, u32>,
221221
t_string: String,
222+
t_optional_string: Option<String>,
222223
#[serde(rename = "")] // empty name becomes the (Default) value in the registry
223224
t_char: char,
224225
t_i8: i8,
@@ -248,11 +249,12 @@ fn main() -> Result<(), Box<dyn Error>> {
248249
t_u64: 123_456_789_101_112,
249250
t_usize: 1_234_567_891,
250251
t_struct: Rectangle {
251-
coords: Coords { x: 55, y: 77 },
252+
coords: Some(Coords { x: 55, y: 77 }),
252253
size: Size { w: 500, h: 300 },
253254
},
254255
t_map: map,
255256
t_string: "test 123!".to_owned(),
257+
t_optional_string: Some("test 456!".to_owned()),
256258
t_char: 'a',
257259
t_i8: -123,
258260
t_i16: -2049,

examples/map_key_serialization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Size {
2222

2323
#[derive(Debug, Serialize, Deserialize, PartialEq)]
2424
struct Rectangle {
25-
coords: Coords,
25+
coords: Option<Coords>,
2626
size: Size,
2727
}
2828

@@ -33,14 +33,14 @@ fn main() -> Result<(), Box<dyn Error>> {
3333
v1.insert(
3434
"first".to_owned(),
3535
Rectangle {
36-
coords: Coords { x: 55, y: 77 },
36+
coords: Some(Coords { x: 55, y: 77 }),
3737
size: Size { w: 500, h: 300 },
3838
},
3939
);
4040
v1.insert(
4141
"second".to_owned(),
4242
Rectangle {
43-
coords: Coords { x: 11, y: 22 },
43+
coords: None,
4444
size: Size { w: 1000, h: 600 },
4545
},
4646
);

examples/serialization.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct Size {
2222

2323
#[derive(Debug, Serialize, Deserialize, PartialEq)]
2424
struct Rectangle {
25-
coords: Coords,
25+
coords: Option<Coords>,
2626
size: Size,
2727
}
2828

@@ -37,6 +37,7 @@ struct Test {
3737
t_struct: Rectangle,
3838
t_map: HashMap<String, u32>,
3939
t_string: String,
40+
t_optional_string: Option<String>,
4041
#[serde(with = "serde_bytes")]
4142
t_bytes: Vec<u8>,
4243
#[serde(rename = "")] // empty name becomes the (Default) value in the registry
@@ -68,11 +69,12 @@ fn main() -> Result<(), Box<dyn Error>> {
6869
t_u64: 123_456_789_101_112,
6970
t_usize: 1_234_567_891,
7071
t_struct: Rectangle {
71-
coords: Coords { x: 55, y: 77 },
72+
coords: Some(Coords { x: 55, y: 77 }),
7273
size: Size { w: 500, h: 300 },
7374
},
7475
t_map: map,
7576
t_string: "test 123!".to_owned(),
77+
t_optional_string: Some("test 456!".to_owned()),
7678
t_bytes: vec![0xDE, 0xAD, 0xBE, 0xEF],
7779
t_char: 'a',
7880
t_i8: -123,

examples/transacted_serialization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Size {
2323

2424
#[derive(Debug, Serialize, Deserialize, PartialEq)]
2525
struct Rectangle {
26-
coords: Coords,
26+
coords: Option<Coords>,
2727
size: Size,
2828
}
2929

@@ -70,7 +70,7 @@ fn main() -> Result<(), Box<dyn Error>> {
7070
t_u64: 123_456_789_101_112,
7171
t_usize: 1_234_567_891,
7272
t_struct: Rectangle {
73-
coords: Coords { x: 55, y: 77 },
73+
coords: Some(Coords { x: 55, y: 77 }),
7474
size: Size { w: 500, h: 300 },
7575
},
7676
t_map: map,

src/common.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ macro_rules! werr {
1515
}
1616

1717
pub(crate) fn to_utf16<P: AsRef<OsStr>>(s: P) -> Vec<u16> {
18-
s.as_ref()
19-
.encode_wide()
20-
.chain(Some(0).into_iter())
21-
.collect()
18+
s.as_ref().encode_wide().chain(Some(0)).collect()
2219
}
2320

2421
pub(crate) fn v16_to_v8(v: &[u16]) -> Vec<u8> {

src/decoder/serialization_serde.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// may not be copied, modified, or distributed
55
// except according to those terms.
66
use super::{DecodeResult, Decoder, DecoderCursor, DecoderError, DECODER_SAM};
7-
use crate::types::FromRegValue;
7+
use crate::{types::FromRegValue, RegValue};
88
use serde::de::*;
99
use std::fmt;
1010

@@ -14,7 +14,7 @@ impl Error for DecoderError {
1414
}
1515
}
1616

17-
impl<'de, 'a> Deserializer<'de> for &'a mut Decoder {
17+
impl<'de> Deserializer<'de> for &mut Decoder {
1818
type Error = DecoderError;
1919
fn deserialize_any<V>(self, visitor: V) -> DecodeResult<V::Value>
2020
where
@@ -36,7 +36,11 @@ impl<'de, 'a> Deserializer<'de> for &'a mut Decoder {
3636
REG_DWORD => visitor.visit_u32(u32::from_reg_value(&v)?),
3737
REG_QWORD => visitor.visit_u64(u64::from_reg_value(&v)?),
3838
REG_BINARY => visitor.visit_byte_buf(v.bytes),
39-
_ => no_impl!("value type deserialization not implemented"),
39+
REG_NONE => visitor.visit_none(),
40+
_ => no_impl!(format!(
41+
"value type deserialization not implemented {:?}",
42+
v.vtype
43+
)),
4044
}
4145
}
4246
_ => no_impl!("deserialize_any"),
@@ -175,9 +179,21 @@ impl<'de, 'a> Deserializer<'de> for &'a mut Decoder {
175179
let v = {
176180
use super::DecoderCursor::*;
177181
match self.cursor {
178-
FieldVal(_, ref name) => {
179-
self.key.get_raw_value(name).map_err(DecoderError::IoError)
180-
}
182+
Start => return visitor.visit_some(&mut *self),
183+
FieldVal(index, ref name) => self
184+
.key
185+
.get_raw_value(name)
186+
.map_err(DecoderError::IoError)
187+
.and_then(|v| match v {
188+
RegValue {
189+
vtype: crate::enums::RegType::REG_NONE,
190+
..
191+
} => {
192+
self.cursor = DecoderCursor::Field(index + 1);
193+
Err(DecoderError::DeserializerError("Found REG_NONE".to_owned()))
194+
}
195+
val => Ok(val),
196+
}),
181197
_ => Err(DecoderError::DeserializerError("Nothing found".to_owned())),
182198
}
183199
};

src/encoder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl Encoder<&Transaction> {
100100
key: &RegKey,
101101
tr: &'a Transaction,
102102
) -> EncodeResult<Encoder<&'a Transaction>> {
103-
key.open_subkey_transacted_with_flags("", &tr, ENCODER_SAM)
103+
key.open_subkey_transacted_with_flags("", tr, ENCODER_SAM)
104104
.map(|k| Encoder::new_transacted(k, tr))
105105
.map_err(EncoderError::IoError)
106106
}

0 commit comments

Comments
 (0)