pub trait SerializableStatewhere
Self: Sized,{
type SerializedStateSize: ArraySize;
// Required methods
fn serialize(&self) -> SerializedState<Self>;
fn deserialize(
serialized_state: &SerializedState<Self>,
) -> Result<Self, DeserializeStateError>;
}Expand description
Types which can serialize the internal state and be restored from it.
§Compatibility
Serialized state can be assumed to be stable across backwards compatible
versions of an implementation crate, i.e. any 0.x.y version of a crate
should be able to decode data serialized with any other 0.x.z version,
but it may not be able to correctly decode data serialized with a non-x
version.
This guarantee is a subject to issues such as security fixes.
§SECURITY WARNING
Serialized state may contain sensitive data.
Required Associated Types§
Sourcetype SerializedStateSize: ArraySize
type SerializedStateSize: ArraySize
Size of serialized internal state.
Required Methods§
Sourcefn serialize(&self) -> SerializedState<Self>
fn serialize(&self) -> SerializedState<Self>
Serialize and return internal state.
Sourcefn deserialize(
serialized_state: &SerializedState<Self>,
) -> Result<Self, DeserializeStateError>
fn deserialize( serialized_state: &SerializedState<Self>, ) -> Result<Self, DeserializeStateError>
Create an object from serialized internal state.
§Errors
If the serialized state could not be deserialized successfully.
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.