pub struct BackendTensorCarrier { /* private fields */ }Expand description
Engine-internal SlotValue wrapping a backend-native tensor
behind a type-erased handle. Built by the engine’s wire-decode
path (decode_typed_fill backend-mediated branch) from the
Backend::materialize_from_wire result; downstream graph ops
downcast inner to the backend’s Self::Tensor to read the
value.
Lifecycle:
- Engine reads an inbound tensor
SlotFill, charges its bytes againstNodeConfig::ingress_byte_budget, and hands theVec<u8>to the backend bound to the destination slot viacrate::roles::BackendRuntime::materialize_from_wire. - Backend returns a
Box<dyn SlotValue>containing this carrier; the engine installs it in the slot table. - On slot overwrite / eviction, the writer reads
SlotValue::charged_bytes(returnsself.charged_bytes) and releases the budget against the engine counter.
clone_fn + wire_encode_fn carry the per-T::Tensor clone /
re-encode shape so the carrier supports the universal
SlotValue contract without a Clone / Serialize bound on
the type-erased inner. The #[derive(bb::Backend)] derive
captures T at the call site and stores these fn pointers in
the carrier; intra-Node clones (clone_boxed) and re-encodes
(to_wire_bytes) route through them.
Implementations§
Source§impl BackendTensorCarrier
impl BackendTensorCarrier
Sourcepub fn from_typed<T>(
tensor: T,
type_hash: u64,
charged_bytes: usize,
backend_ref: ComponentRef,
) -> BackendTensorCarrier
pub fn from_typed<T>( tensor: T, type_hash: u64, charged_bytes: usize, backend_ref: ComponentRef, ) -> BackendTensorCarrier
Construct a carrier from the backend’s already-typed
Self::Tensor. The #[derive(bb::Backend)] materialize
bridge is the canonical caller; the constructor is pub so
derive expansions in downstream crates can call it, but the
engine-side fields (charged_bytes, backend_ref) get
stamped via [Self::stamp_engine_fields] immediately after
the bridge returns so authoring code never holds a carrier
with stale accounting.
Sourcepub fn type_hash(&self) -> u64
pub fn type_hash(&self) -> u64
Borrow the carrier’s wire-type hash. Used by the wire-encode path and by tests that assert a fill’s type discriminator round-trips through the carrier.
Sourcepub fn backend_ref(&self) -> ComponentRef
pub fn backend_ref(&self) -> ComponentRef
Borrow the producing backend’s ComponentRef. Used by
re-encode + introspection.
Sourcepub fn downcast_inner<T>(&self) -> Option<&T>
pub fn downcast_inner<T>(&self) -> Option<&T>
Downcast the type-erased inner tensor to the backend’s
concrete Self::Tensor. Engine consumers reach the tensor
through this accessor; the inner field stays
pub(crate) so external code can’t dodge the downcast +
type-hash validation step.
Trait Implementations§
Source§impl Debug for BackendTensorCarrier
impl Debug for BackendTensorCarrier
Source§impl SlotValue for BackendTensorCarrier
impl SlotValue for BackendTensorCarrier
Source§fn into_any_boxed(self: Box<BackendTensorCarrier>) -> Box<dyn Any + Sync + Send>
fn into_any_boxed(self: Box<BackendTensorCarrier>) -> Box<dyn Any + Sync + Send>
Box<dyn SlotValue> as Box<dyn Any> for
Box::downcast. Required because the SlotValue and
Any vtables are distinct even though SlotValue: Any.Source§fn clone_boxed(&self) -> Box<dyn SlotValue>
fn clone_boxed(&self) -> Box<dyn SlotValue>
Source§fn to_wire_bytes(&self) -> Result<Vec<u8>, SlotValueError>
fn to_wire_bytes(&self) -> Result<Vec<u8>, SlotValueError>
clone_boxed instead.Source§fn type_hash(&self) -> u64
fn type_hash(&self) -> u64
std::any::type_name::<T>(); receiver decodes only on a
matching hash.Source§fn charged_bytes(&self) -> usize
fn charged_bytes(&self) -> usize
NodeConfig::ingress_byte_budget. Slot-table eviction calls
this to release the charge. Default 0 — only
ingress-derived carriers register a non-zero resolver via
[register_charged_bytes!].