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,
) -> Self
pub fn from_typed<T>( tensor: T, type_hash: u64, charged_bytes: usize, backend_ref: ComponentRef, ) -> Self
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: Any + Send + Sync + 'static>(&self) -> Option<&T>
pub fn downcast_inner<T: Any + Send + Sync + 'static>(&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<Self>) -> Box<dyn Any + Send + Sync>
fn into_any_boxed(self: Box<Self>) -> Box<dyn Any + Send + Sync>
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!].Auto Trait Implementations§
impl !RefUnwindSafe for BackendTensorCarrier
impl !UnwindSafe for BackendTensorCarrier
impl Freeze for BackendTensorCarrier
impl Send for BackendTensorCarrier
impl Sync for BackendTensorCarrier
impl Unpin for BackendTensorCarrier
impl UnsafeUnpin for BackendTensorCarrier
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedComponent for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request