script::dom::bindings::serializable

Trait Serializable

Source
pub(crate) trait Serializable: DomObject
where Self: Sized,
{ type Id: Copy + Eq + Hash + IntoStorageKey + From<StorageKey>; type Data; // Required methods fn serialize(&self) -> Result<(Self::Id, Self::Data), ()>; fn deserialize( owner: &GlobalScope, serialized: Self::Data, can_gc: CanGc, ) -> Result<DomRoot<Self>, ()> where Self: Sized; fn serialized_storage( data: StructuredData<'_>, ) -> &mut Option<HashMap<Self::Id, Self::Data>>; fn deserialized_storage( reader: &mut StructuredDataReader, ) -> &mut Option<HashMap<StorageKey, DomRoot<Self>>>; }
Expand description

Interface for serializable platform objects. https://html.spec.whatwg.org/multipage/#serializable

Required Associated Types§

Required Methods§

Source

fn serialize(&self) -> Result<(Self::Id, Self::Data), ()>

Source

fn deserialize( owner: &GlobalScope, serialized: Self::Data, can_gc: CanGc, ) -> Result<DomRoot<Self>, ()>
where Self: Sized,

Source

fn serialized_storage( data: StructuredData<'_>, ) -> &mut Option<HashMap<Self::Id, Self::Data>>

Returns the field of StructuredDataReader/[StructuredDataWriter] that should be used to read/store serialized instances of this type.

Source

fn deserialized_storage( reader: &mut StructuredDataReader, ) -> &mut Option<HashMap<StorageKey, DomRoot<Self>>>

Returns the field of StructuredDataReader that should be used to store deserialized instances of this type.

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.

Implementors§