Skip to content

Commit

Permalink
release: patch 1.0.1 (#13)
Browse files Browse the repository at this point in the history
* chore: remove debug vals and add enum tests (#10)

* chore: add enum tests

* chore: remove debug

* chore: fix readme (#11)

* release: version bump (#12)
  • Loading branch information
is-it-ayush authored Feb 28, 2024
1 parent 89a62fd commit 4c4555e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "rust-fr"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
description = "a simple, non-self-describing data-interchange format."
repository = "https://github.com/is-it-ayush/rust-fr"
license-file = "LICENSE.md"
readme = "README.md"
keywords = ["rust", "fr", "data-interchange", "format", "toy"]
keywords = ["rust_fr", "encoding", "data-interchange", "format", "serde"]
categories = ["encoding", "data-structures"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ or elsewhere.

### format specification.

- The format is not self-describing.
- The format is non-self-describing.
- Primitive types are serialized as is.
- bool: 0 -> false, 1 -> true (1 byte)
- bool: 0 -> false, 1 -> true (1 bit)
- i8, i16, i32, i64: as is.
- u8, u16, u32, u64: as is.
- f32, f64: as is.
Expand Down
11 changes: 0 additions & 11 deletions src/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,23 +646,17 @@ impl<'de, 'a> MapAccess<'de> for MapDeserializer<'a, 'de> {
where
K: serde::de::DeserializeSeed<'de>,
{
println!("map(): key--start");
// if at end of map; exit
if self.deserializer.peek_token(Delimiter::Map)? {
println!("map(): exit");
return Ok(None);
}
println!("map(): key--loop");
// make not first; deserialize next key_1
self.first = false;
let value = seed.deserialize(&mut *self.deserializer).map(Some)?;
println!("map(): deserialied_key");
if !self.deserializer.peek_token(Delimiter::MapKey)? {
return Err(Error::ExpectedDelimiter(Delimiter::MapKey));
}
println!("map(): eating key delimiter");
self.deserializer.eat_token(Delimiter::MapKey)?;
println!("map(): key--end");
Ok(value)
}

Expand All @@ -674,16 +668,11 @@ impl<'de, 'a> MapAccess<'de> for MapDeserializer<'a, 'de> {
where
V: serde::de::DeserializeSeed<'de>,
{
println!("map(): value--start");
println!("peeking_map_value");
let value = seed.deserialize(&mut *self.deserializer)?;
println!("map(): deserialied_value");
if !self.deserializer.peek_token(Delimiter::MapValue)? {
return Err(Error::ExpectedDelimiter(Delimiter::MapValue));
}
println!("map(): eating value delimiter");
self.deserializer.eat_token(Delimiter::MapValue)?;
println!("map(): value--end");
Ok(value)
}
}
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ mod tests {
c: Option<u8>,
d: Option<String>,
e: Primitives,
f: Vec<AnEnum>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
enum AnEnum {
A(u8),
B { a: u8, b: u16 },
C,
}

#[test]
Expand Down Expand Up @@ -115,6 +123,7 @@ mod tests {
l: 'a',
m: "hello".to_string(),
},
f: vec![AnEnum::A(1), AnEnum::B { a: 1, b: 2 }, AnEnum::C],
};

// Serialize
Expand Down

0 comments on commit 4c4555e

Please sign in to comment.