Skip to main content

RuntimeResourceRef

Struct RuntimeResourceRef 

Source
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 TypedBus

The 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<'_>

Source

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.

Source

pub fn dependency<T>(&self, slot_name: &str) -> Result<&T, DependencyError>
where T: 'static,

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)?;
Source

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.

Source

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).

Source

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.

Source

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).

Source

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.

Source

pub fn publish_bus(&mut self, event: NodeEvent)

Convenience for publishing events to the in-Node bus.

Source

pub fn open_completion<R, E>(&mut self) -> CompletionHandle<R, E>
where R: Serialize, E: Display,

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedComponent for T
where T: Any + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more