pub trait Serializable<D: DomTypes>: DomObject + MarkedAsSerializableInIdlwhere
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§
Sourcefn deserialize(
cx: &mut JSContext,
owner: &D::GlobalScope,
serialized: Self::Data,
) -> Result<DomRoot<Self>, ()>where
Self: Sized,
fn deserialize(
cx: &mut JSContext,
owner: &D::GlobalScope,
serialized: Self::Data,
) -> Result<DomRoot<Self>, ()>where
Self: Sized,
Sourcefn serialized_storage<'a>(
data: StructuredData<'a, '_>,
) -> &'a mut Option<FxHashMap<NamespaceIndex<Self::Index>, Self::Data>>
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".