script::dom::bindings::serializable

Trait Serializable

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

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

Required Associated Types§

Required Methods§

Source

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

Source

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

Source

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

Returns the field of [StructuredDataReader]/[StructuredDataWriter] that should be used to read/store serialized 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§