pub struct ComponentHandle {
pub type_name: &'static str,
pub package: ComponentPackage,
pub instance_id: u32,
pub serialize_fn: fn(&(dyn ErasedComponent + 'static)) -> Vec<u8>,
pub restore_fn: fn(&[u8]) -> Result<Box<dyn ErasedComponent>, RestoreError>,
pub state_bytes: Vec<u8>,
}Expand description
Owned wrapper that travels through the ModelProto → Node pipeline. Carries captured fn pointers + state bytes.
Fields§
§type_name: &'static strStable type identifier.
package: ComponentPackageOrigin tag.
instance_id: u32Per-Node instance disambiguator assigned by install.
serialize_fn: fn(&(dyn ErasedComponent + 'static)) -> Vec<u8>Monomorphized T::serialize via downcast.
restore_fn: fn(&[u8]) -> Result<Box<dyn ErasedComponent>, RestoreError>Monomorphized T::restore.
state_bytes: Vec<u8>Serialized state captured at build or snapshot time.
Implementations§
Source§impl ComponentHandle
impl ComponentHandle
Sourcepub fn materialize(&self) -> Result<Box<dyn ErasedComponent>, RestoreError>
pub fn materialize(&self) -> Result<Box<dyn ErasedComponent>, RestoreError>
Materialize a fresh instance via restore_fn(state_bytes).
Sourcepub fn capture_state(
&self,
instance: &(dyn ErasedComponent + 'static),
) -> Vec<u8> ⓘ
pub fn capture_state( &self, instance: &(dyn ErasedComponent + 'static), ) -> Vec<u8> ⓘ
Capture state from a live &dyn ErasedComponent.
Sourcepub fn from_concrete<T>(instance: &T, instance_id: u32) -> ComponentHandlewhere
T: ConcreteComponent,
pub fn from_concrete<T>(instance: &T, instance_id: u32) -> ComponentHandlewhere
T: ConcreteComponent,
Build from a live &T: ConcreteComponent. Captures
monomorphized serialize/restore + freezes current bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ComponentHandle
impl RefUnwindSafe for ComponentHandle
impl Send for ComponentHandle
impl Sync for ComponentHandle
impl Unpin for ComponentHandle
impl UnsafeUnpin for ComponentHandle
impl UnwindSafe for ComponentHandle
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