Releases: khonsulabs/pot
v3.0.1
Added
-
Compatibilityis a new enum that controls compatibility of serialization and
deserialization.Compatibility::Fullis the default compatibility level in
v3.x, and it serializes data in a way that even Potv1.0deserializers can
deserialize.Compatibility::V4is a new serialization format that serializes enum
variants without associated data in a way that allowsValuedeserialization
to be done unambiguously. See #11 for an example of this issue. This bug
only affecteddeserialize_any-type deserialization. Typical deserialization
works correctly.Compatibility can be configured using these new APIs:
Config::compatibilitySerializer::new_with_compatibilitySymbolMap::with_compatibilitySymbolMap::set_compatibility
v3.0.0
Breaking Changes
-
#9
Value::from_serializenow returns aResult. Previously, if a Serialize
implementation returned an error, the function would panic. Thanks to
@wackbyte for finding this. -
Reader::buffered_read_bytesnow takes a third parameter,scratch: &mut Vec<u8>and returns a new typeBufferedBytes. This allows callers to supply
a buffer for reading bytes into rather than requiring implementors allocate
new buffers. -
PartialEqforValuehas been changed such that if the bytes contained by a
string match the bytes contained by a byte value, the values now compare as
equal. Previously, all discriminants required exact matches.This was done due to Pot not knowing whether a value is a string or bytes when
serialized. Bytes are auto-promoted to string if the bytes are valid UTF-8 in
Value deserialization. -
SymbolMapnow utilizes a new structureSymbolListfor managing symbols.
This type optimizes storage of symbols when they are not borrowed from the
deserialization source. -
format::write_atom_headerno longer accepts an option for thearg
parameter. -
format::read_atomnow accepts ascratch: &mut Vec<u8>parameter which is
used when reading an associatedNucleus::Bytes. WhenNucleus::Bytes
containsBufferedBytes::Scratch,scratchwill contain the bytes contained
in the atom. -
SymbolMapRefis now a struct with private contents. -
Erroris now#[non_exhaustive]. -
format::Floatandformat::Integerno longer implement
Serialize/Deserialize. These implementations were derived but never
actually used. To improve this crate's build parallelization, a decision was
made to remove these usages of serde's derive macro. Implementing these traits
would be trivial, but the crate maintainer doesn't believe anyone is actually
using these implementations, so they were intentionally skipped. Please file
an issue if this affected you and you would like to see these implementations
added again.
Changed
pot::Result<T>is nowpot::Result<T,E = pot::Error>. This avoids issues
with other code whenpot::Resultis imported.ValueIteris now exported. This is the type returned fromValue::values().- The Minimum Supported Rust Version (MSRV) has been set to 1.70. This MSRV was
chosen at the time due to dependencies also requiring this MSRV. - Tracing instrumentation has been changed from the default level of INFO to
TRACE. - This crate no longer activates the
derivefeature ofserde.
Added
-
OwnedValuenow implementsFromforValue<'_>and&Value<'_>. -
Valuenow implementsFromIterator<T>whereT: Into<Value<'a>>. The
result will be the variantValue::Sequence. -
Valuenow implementsFromIterator<(K, V)>whereK: Into<Value<'a>>, V: Into<Value<'a>>. The result will be the variantValue::Mappings. -
de::SymbolMapandser::SymbolMapnow both implementSerializeand
Deserializeusing the same serialization strategy. This allows preshared
dictionaries to be used, and for state to be saved and restored. -
de::SymbolMapandser::SymbolMaphave new convenience methods that allow
serializing and deserializing values directly:de::SymbolMap::deserialize_slicede::SymbolMap::deserialize_fromser::SymbolMap::serialize_to_vecser::SymbolMap::serialize_to
v2.0.0
Breaking Changes
- The
formatmodule has been refactored to passWriteby value rather than
by mutable reference. Most code should not be affected becauseWriteis
implemented for&mut Write.
Changed
-
The unit type
()andOption::Noneare more fuzzy when deserializing. If
users deserialize a value that was serialized asNoneor(), the default
value will be returned rather than an error, when possible. For example:let unit = pot::to_vec(&())?; assert_eq!(pot::from_slice(&unit).unwrap(), 0_u32) let none = pot::to_vec(&Option::<bool>::None)?; assert_eq!(pot::from_slice(&unit).unwrap(), 0_u32)
This is not practically useful for most users, but when designing traits that
have associated serializable types, sometimes it's useful to use()when no
data needs to be stored. However, it can be painful to update existing data
when switching between()and other types, as Serde offers no built-in
transmutation. Pot now offers this internally.
Added
Value::from_serializeandValue::deserialize_ashave been added, allowing
Valueto be transmuted directly from types that implementSerializeand
Deserialize.OwnedValueis a new-type wrapper aroundValue<'static>that can be used in
situations whereDeserializeOwnedis a requirement. This type is needed
becauseValue<'a>can borrow from the source of the deserialization, and
this flexibility causes lifetime errors when trying to deserialize a
Value<'static>asDeserializeOwned.
v1.0.2
v1.0.1
v1.0.0
v1.0.0-rc.4
Changed
- Fixed compilation error caused by a new dependency upgrade.
v1.0.0-rc.3
Changed
from_readerandConfig::deserialize_fromtoDeserializeOwned. This
prevents errors at compile time that would arise at runtime when deserializing
instead.
v1.0.0-rc.2
Added
Confignow implementsCloneandDebug.
v1.0.0-rc.1
This release focused on adding more unit tests to test both positive and negative flows. At the release of v0.1.0-alpha.3, the code coverage reported at 79.65%. This release brings that metric to 92.78%, and some of the missing coverage is due to the coverage tools not working fully in certain circumstances. The current report can always be viewed here.
Added
- Added the
Valuetype, allowing deserializing arbitrary Pot payloads without its
original data structure.
Fixed
- Small fixes when packing floats and integers. No breaking changes, as the
incorrect code would just use more space than needed for certain values.