pub struct RuntimeResourceRef<'a> {
pub peers: PeerCtx<'a>,
pub net: NetCtx<'a>,
pub time: TimeCtx<'a>,
pub syscall: SyscallCtx<'a>,
pub bus: &'a mut TypedBus,
pub ingress: Arc<IngressQueue>,
pub components: ComponentsView<'a>,
pub current: CurrentCallCtx<'a>,
}Expand description
Engine-resource handle threaded into every dispatch_atomic
call. Per docs/ENGINE.md §10. Fields are grouped by concern -
peers/net/time/syscall carry the framework primitive
references; current carries per-op state; bus/ingress
stay top-level; components exposes the cross-component
read-only surface.
Fields§
§peers: PeerCtx<'a>Per-peer state (gate, backoff, governor, addresses).
net: NetCtx<'a>Network/transport state (outbound queue, RTT, requests, dedup).
time: TimeCtx<'a>Time / scheduling state.
syscall: SyscallCtx<'a>Syscall-side state (storage, RNG, latches, app-event drain).
bus: &'a mut TypedBusThe in-Node typed event bus.
ingress: Arc<IngressQueue>Shared handle to the Node’s ingress queue.
components: ComponentsView<'a>Read-only view onto sibling components registered on the Node.
current: CurrentCallCtx<'a>State scoped to the currently-dispatching op.
Implementations§
Source§impl RuntimeResourceRef<'_>
impl RuntimeResourceRef<'_>
Sourcepub fn local_addresses(&self) -> &[Address]
pub fn local_addresses(&self) -> &[Address]
Ordered local-address bag for this Node. Reads the
AddressBook entry keyed by self.current.self_peer; returns
an empty slice when no local addresses are registered.
Wire ops + identity-bearing protocol replies (Announce,
Handshake) stamp this onto their outbound envelopes so
receivers can dial back on every reachable interface.
Sourcepub fn dependency<T: 'static>(
&self,
slot_name: &str,
) -> Result<&T, DependencyError>
pub fn dependency<T: 'static>( &self, slot_name: &str, ) -> Result<&T, DependencyError>
Typed accessor for an author-declared dependency. Resolves
slot_name against the engine’s generic slot registry and
downcasts the bound ErasedComponent to &T.
In production the resolution is guaranteed to succeed -
resolve_component_dependencies verifies at compile time
that every #[depends(<role> = "<slot>")] declaration
matches a bound concrete of the right role. A miss here is
either a test fixture bypassing the compiler pipeline or a
framework invariant breach.
// Inside a Component's dispatch_atomic / Contract impl:
let backend = ctx
.dependency::<MyCpuBackend>("compute")
.expect("compiler verified");
let result = backend.matmul(&lhs, &rhs)?;Sourcepub fn estimate_wire_budget_ns(
&self,
target: NodeSiteId,
chain: Option<ChainContext>,
static_default_ns: u64,
) -> u64
pub fn estimate_wire_budget_ns( &self, target: NodeSiteId, chain: Option<ChainContext>, static_default_ns: u64, ) -> u64
-ii - convenience helper
that walks the hierarchical fallback in
crate::framework::rtt_tracker::RttTracker to pick the
effective deadline for a wire round-trip.
chain_id + hop_index come from the compiler-stamped
chain_targets / chain_depth metadata on the current
NodeProto (read from
[Self::current_node_metadata] via
Self::read_chain_context); pass None for control-plane
sends that have no chain context.
Sourcepub fn read_chain_context(&self) -> Option<ChainContext>
pub fn read_chain_context(&self) -> Option<ChainContext>
Read the compiler-stamped chain_targets + chain hop
(encoded in chain_depth metadata) off the current NodeProto
and convert them into an crate::framework::rtt_tracker::ChainContext.
Returns None when no chain metadata is present (the Send is
a fire-and-forget escape hatch or a control-plane round-trip).
Sourcepub fn observe_wire_round_trip(
&mut self,
target: NodeSiteId,
chain: Option<ChainContext>,
elapsed_ns: u64,
now_ns: u64,
)
pub fn observe_wire_round_trip( &mut self, target: NodeSiteId, chain: Option<ChainContext>, elapsed_ns: u64, now_ns: u64, )
Record a wire round-trip sample into the RTT tracker. Called
on response landing (after the matching WireResponseLanded
event surfaces the elapsed time) so all the hierarchical-
fallback EMA tiers stay current.
Sourcepub fn allocate_command_id(&mut self) -> CommandId
pub fn allocate_command_id(&mut self) -> CommandId
Mint a fresh CommandId via the engine’s monotonic counter.
Used by async-suspending syscalls (After, Sleep,
BootstrapDispatch).
Sourcepub fn complete_command(
&mut self,
cmd_id: CommandId,
results: Vec<(String, Box<dyn SlotValue>)>,
)
pub fn complete_command( &mut self, cmd_id: CommandId, results: Vec<(String, Box<dyn SlotValue>)>, )
Record a CommandId completion for the engine to drain after
dispatch_atomic returns. Used by ProtocolRuntime impls +
any role impl that returned DispatchResult::Async. Invoking
this in the same call lets the consumer fire in the same poll
cycle via the engine’s catch-up drain.
Sourcepub fn publish_bus(&mut self, event: NodeEvent)
pub fn publish_bus(&mut self, event: NodeEvent)
Convenience for publishing events to the in-Node bus.
Sourcepub fn open_completion<R, E>(&mut self) -> CompletionHandle<R, E>
pub fn open_completion<R, E>(&mut self) -> CompletionHandle<R, E>
Open a completion handle for an async Contract method. The
caller receives a fresh CommandId + a shared
CompletionSink backed by the Node’s ingress queue. The
user’s Contract method holds the handle past the dispatch
return and calls CompletionHandle::complete when work
finishes. The dispatch arm returns
DispatchResult::Async(handle.cmd_id()) so the engine parks
the op until the completion lands.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for RuntimeResourceRef<'a>
impl<'a> !UnwindSafe for RuntimeResourceRef<'a>
impl<'a> Freeze for RuntimeResourceRef<'a>
impl<'a> Send for RuntimeResourceRef<'a>
impl<'a> Sync for RuntimeResourceRef<'a>
impl<'a> Unpin for RuntimeResourceRef<'a>
impl<'a> UnsafeUnpin for RuntimeResourceRef<'a>
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