pub(crate) trait Serializable: DomObjectwhere
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§
type Id: Copy + Eq + Hash + IntoStorageKey + From<StorageKey>
type Data
Required Methods§
Sourcefn deserialize(
owner: &GlobalScope,
serialized: Self::Data,
can_gc: CanGc,
) -> Result<DomRoot<Self>, ()>where
Self: Sized,
fn deserialize(
owner: &GlobalScope,
serialized: Self::Data,
can_gc: CanGc,
) -> Result<DomRoot<Self>, ()>where
Self: Sized,
Sourcefn serialized_storage(
data: StructuredData<'_>,
) -> &mut Option<HashMap<Self::Id, Self::Data>>
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.
Sourcefn deserialized_storage(
reader: &mut StructuredDataReader,
) -> &mut Option<HashMap<StorageKey, DomRoot<Self>>>
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.