pub trait Versioned: Serialize + for<'de> Deserialize<'de> {
// Provided methods
fn max_serialized_size() -> Option<u64> { ... }
fn deserialize_from<R>(reader: &mut R, _version: Version) -> Result<Self>
where R: Read + ?Sized,
for<'de> Self: Deserialize<'de> { ... }
fn serialize_into<W>(&self, writer: &mut W) -> Result<()>
where W: Write,
Self: Serialize { ... }
}Expand description
This trait is assigned to all versions of a versioned type and is the only means of serialization/deserialization we use.
It also allows versions to serialize/deserialize themselves differently on a per-version basis. Doing this here enforces consistency at a given filesystem version.
Provided Methods§
Sourcefn max_serialized_size() -> Option<u64>
fn max_serialized_size() -> Option<u64>
Maximum size of a serialized version of this type. Serialization and deserialization will fail if the limit is exceeded. If None, there is no limit. None is preferred over u64::MAX because serializing and deserializing with a limit has runtime overhead.
fn deserialize_from<R>(reader: &mut R, _version: Version) -> Result<Self>
fn serialize_into<W>(&self, writer: &mut W) -> Result<()>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.