pub trait HashConsSerializerState: Sized {
// Required methods
fn record_serialized<T: Mappable>(&self, id: HashConsId) -> Option<bool>;
fn record_deserialized<T: Mappable>(
&self,
id: HashConsId,
value: HashConsed<T>,
);
fn get_deserialized_val<T: Mappable>(
&self,
id: HashConsId,
) -> Option<HashConsed<T>>;
}Expand description
HashCons supports serializing each value to a unique id in order to serialize
highly-shared values without explosion.
Note that the deduplication scheme is highly order-dependent: we serialize the real value
the first time it comes up, and use ids only subsequent times. This relies on the fact that
derive(Serialize, Deserialize) traverse the value in the same order.
Required Methods§
Sourcefn record_serialized<T: Mappable>(&self, id: HashConsId) -> Option<bool>
fn record_serialized<T: Mappable>(&self, id: HashConsId) -> Option<bool>
Record that this type is being serialized. Return None if we’re not deduplicating
values, otherwise return whether this item was newly recorded.
Sourcefn record_deserialized<T: Mappable>(&self, id: HashConsId, value: HashConsed<T>)
fn record_deserialized<T: Mappable>(&self, id: HashConsId, value: HashConsed<T>)
Record that we deserialized this type.
Sourcefn get_deserialized_val<T: Mappable>(
&self,
id: HashConsId,
) -> Option<HashConsed<T>>
fn get_deserialized_val<T: Mappable>( &self, id: HashConsId, ) -> Option<HashConsed<T>>
Find the previously-deserialized type with that id.
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.