Skip to main content

Node

Struct Node 

Source
pub struct Node<S: NodeState = Attached> { /* private fields */ }
Expand description

Node — Hyper wired to a runtime configuration (and optionally a workload).

A Node<Init> is produced by Node::from_config_file or Node::from_hyper; it carries Hyper + actr_config::RuntimeConfig but has not yet been attached. Call one of the attach methods to progress into Node<Attached>, then register().start() into a running ActrRef:

Node::from_config_file(path) -> Node<Init>
    .attach(package)         -> Node<Attached>   (attach: wasm / dyn lib)
    .link(workload)          -> Node<Attached>   (link: static lib)

Node<Attached>.register(ais) -> Node<Registered>
Node<Registered>.start()     -> ActrRef

The default type parameter Attached means writing Node unqualified refers to the attached state; start() only exists on Node<Registered>.

Implementations§

Source§

impl Node

Source

pub async fn from_config_file( path: impl AsRef<Path>, ) -> Result<Node<Init>, HyperError>

Load actr.toml from disk, build the underlying Hyper from the [hyper] section (or an explicit [[trust]] / [hyper.trust] anchor set), and return a Node<Init> ready to attach a workload.

The caller is expected to drive the typestate chain themselves:

let actr_ref = Node::from_config_file("actr.toml").await?
    .attach(&package).await?
    .register(&ais_endpoint).await?
    .start().await?;

For a one-shot sugar covering the entire chain see Node::run_from_config.

Source

pub fn from_hyper(hyper: Hyper, runtime_config: RuntimeConfig) -> Node<Init>

Escape-hatch constructor: wrap an already-built Hyper plus a pre-loaded actr_config::RuntimeConfig into a Node<Init>.

Use this when you need direct control over HyperConfig construction (custom trust chain, injected platform provider, etc.) and cannot drive the whole flow through Node::from_config_file.

Source

pub async fn run_from_config( path: impl AsRef<Path>, package: &WorkloadPackage, ) -> Result<ActrRef, HyperError>

One-shot sugar: from_config_file(path).attach(package).register().start().

Loads the runtime configuration from path, attaches the given workload package, registers with AIS at the [ais_endpoint] URL from the config, and starts the node, returning a live ActrRef. Use the typestate chain directly when you need to interleave create_network_event_handle or swap in a custom service_spec via register_with.

Source§

impl Node<Init>

Source

pub fn runtime_config(&self) -> &RuntimeConfig

Read-only view of the runtime configuration pending attachment. Useful for callers that need to configure observability / tracing subscribers from the config before driving attach.

Source

pub fn with_actor_type(self, actor_type: ActrType) -> Self

Override the runtime actor type before attaching or linking a workload.

Node::from_config_file can synthesize a placeholder actor type when the runtime config has no package manifest. Linked/static hosts use this method to provide the concrete actor identity used for AIS registration.

Source§

impl Node<Init>

Source

pub async fn attach( self, package: &WorkloadPackage, ) -> Result<Node<Attached>, HyperError>

Bind a verified WorkloadPackage to this node.

Equivalent to the former Hyper::attach — verifies the package signature through the configured TrustProvider, loads its guest binary (WASM or dynclib), and advances the node to Node<Attached>. Attach a packaged workload (wasm / dyn lib) to this node.

Link a generic actr_framework::Workload implementation (static lib) into this node.

This is the preferred link path for Rust hosts: the workload is wrapped in a [workload::WorkloadAdapter] so that its associated actr_framework::MessageDispatcher drives inbound RPC dispatch and its hook methods are bridged into the node’s observer plumbing.

Source§

impl Node<Attached>

Source

pub async fn register( self, ais_endpoint: &str, ) -> Result<Node<Registered>, HyperError>

Register with AIS, obtain an AId credential, and inject it into this attached node. Consumes Node<Attached> and returns Node<Registered>.

realm_id, acl, and realm_secret come from the attached [RuntimeConfig]; service_spec is derived from the package’s proto exports when a package-backed attach was used. Linked attachments register from the runtime config’s actor metadata instead.

Source

pub async fn register_with( self, ais_endpoint: &str, service_spec: Option<ServiceSpec>, ) -> Result<Node<Registered>, HyperError>

Register with AIS using an explicit service_spec.

This skips package-based service_spec derivation for package-backed attachments. Linked attachments use the supplied service_spec together with the runtime config’s actor metadata.

Source

pub fn create_network_event_handle( &mut self, debounce_ms: u64, ) -> NetworkEventHandle

Create a network event handle for platform callbacks. Must be called before Node::start.

Source

pub fn ais_endpoint(&self) -> &str

AIS endpoint URL resolved from the attached [RuntimeConfig]. Convenience accessor for callers that just drove from_config_file

  • attach and need the endpoint to pass into register.
Source§

impl Node<Registered>

Source

pub async fn start(self) -> ActorResult<ActrRef>

Start the attached, registered node and return the live ActrRef.

Source

pub fn create_network_event_handle( &mut self, debounce_ms: u64, ) -> NetworkEventHandle

Create a network event handle for platform callbacks. Must be called before Node::start.

Auto Trait Implementations§

§

impl<S = Attached> !Freeze for Node<S>

§

impl<S = Attached> !RefUnwindSafe for Node<S>

§

impl<S = Attached> !UnwindSafe for Node<S>

§

impl<S> Send for Node<S>
where S: Send,

§

impl<S> Sync for Node<S>
where S: Sync,

§

impl<S> Unpin for Node<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Node<S>

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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