#[repr(C)]pub struct DatasetMergeCallback {
pub cb: DatasetMergeCallbackType,
pub callable: OptionRefAny,
}Expand description
A callback function used to merge the state of an old dataset into a new one.
This enables components with heavy internal state (video players, WebGL contexts) to preserve their resources across frames, while the DOM tree is recreated.
The callback receives both the old and new datasets as RefAny (cheap shallow clones)
and returns the dataset that should be used for the new node.
§Example
ⓘ
fn merge_video_state(new_data: RefAny, old_data: RefAny) -> RefAny {
// Transfer heavy resources from old to new
if let (Some(mut new), Some(old)) = (
new_data.downcast_mut::<VideoState>(),
old_data.downcast_ref::<VideoState>()
) {
new.decoder = old.decoder.take();
new.gl_texture = old.gl_texture.take();
}
new_data // Return the merged state
}Fields§
§cb: DatasetMergeCallbackTypeThe function pointer that performs the merge.
Signature: fn(new_data: RefAny, old_data: RefAny) -> RefAny
callable: OptionRefAnyOptional callable for FFI language bindings (Python, etc.)
When set, the FFI layer can invoke this instead of cb.
Trait Implementations§
Source§impl Clone for DatasetMergeCallback
impl Clone for DatasetMergeCallback
Source§fn clone(&self) -> DatasetMergeCallback
fn clone(&self) -> DatasetMergeCallback
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DatasetMergeCallback
impl Debug for DatasetMergeCallback
Source§impl From<extern "C" fn(RefAny, RefAny) -> RefAny> for DatasetMergeCallback
Allow creating DatasetMergeCallback from a raw function pointer.
This enables the Into<DatasetMergeCallback> pattern for Python bindings.
impl From<extern "C" fn(RefAny, RefAny) -> RefAny> for DatasetMergeCallback
Allow creating DatasetMergeCallback from a raw function pointer.
This enables the Into<DatasetMergeCallback> pattern for Python bindings.
Source§fn from(cb: DatasetMergeCallbackType) -> Self
fn from(cb: DatasetMergeCallbackType) -> Self
Converts to this type from the input type.
Source§impl Hash for DatasetMergeCallback
impl Hash for DatasetMergeCallback
Source§impl Ord for DatasetMergeCallback
impl Ord for DatasetMergeCallback
Source§fn cmp(&self, other: &DatasetMergeCallback) -> Ordering
fn cmp(&self, other: &DatasetMergeCallback) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for DatasetMergeCallback
impl PartialEq for DatasetMergeCallback
Source§impl PartialOrd for DatasetMergeCallback
impl PartialOrd for DatasetMergeCallback
impl Eq for DatasetMergeCallback
impl StructuralPartialEq for DatasetMergeCallback
Auto Trait Implementations§
impl Freeze for DatasetMergeCallback
impl RefUnwindSafe for DatasetMergeCallback
impl Send for DatasetMergeCallback
impl Sync for DatasetMergeCallback
impl Unpin for DatasetMergeCallback
impl UnwindSafe for DatasetMergeCallback
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more