Skip to main content

Serializable

Trait Serializable 

Source
pub trait Serializable<D: DomTypes>: DomObject + MarkedAsSerializableInIdl
where Self: Sized,
{ type Index: Copy + Eq + Hash; type Data; // Required methods fn serialize( &self, no_gc: &NoGC, ) -> Result<(NamespaceIndex<Self::Index>, Self::Data), ()>; fn deserialize( cx: &mut JSContext, owner: &D::GlobalScope, serialized: Self::Data, ) -> Result<DomRoot<Self>, ()> where Self: Sized; fn serialized_storage<'a>( data: StructuredData<'a, '_>, ) -> &'a mut Option<FxHashMap<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, no_gc: &NoGC, ) -> Result<(NamespaceIndex<Self::Index>, Self::Data), ()>

Source

fn deserialize( cx: &mut JSContext, owner: &D::GlobalScope, serialized: Self::Data, ) -> Result<DomRoot<Self>, ()>
where Self: Sized,

Source

fn serialized_storage<'a>( data: StructuredData<'a, '_>, ) -> &'a mut Option<FxHashMap<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".

Implementors§