Struct ockam::SystemBuilder

source ·
pub struct SystemBuilder<C, M>
where C: Send + 'static, M: Message,
{ /* private fields */ }
Expand description

An abstraction to build a worker system graph

When creating a worker system it’s important to initialise each handler with the set of internal addresses that it must communicate with. This structure aims to make initialisation easier.

Implementations§

source§

impl<C, M> SystemBuilder<C, M>
where C: Send + 'static, M: Message,

source

pub fn new() -> Self

Create an empty SystemBuilder

source

pub fn add<A, S, H>( &mut self, addr: A, id: S, handler: H ) -> HandlerBuilder<'_, C, M>
where A: Into<Address>, S: Into<String>, H: SystemHandler<C, M> + Send + 'static,

Add a new handler to this SystemBuilder

You must at least provide ONE route path (via .default(addr) or .condition(cond, addr)), or else initialisation will fail.

source

pub fn get_addr(&self, id: impl Into<String>) -> Option<Address>

Get the address of a previously added SystemHandler

source

pub fn set_entry<A: Into<Address>>(&mut self, addr: A)

Specify an entry-point for the soon-to-be-built system

source

pub fn chain_default<A, H>( &mut self, addr: A, prev_id: impl Into<String>, id: impl Into<String>, handler: H ) -> HandlerBuilder<'_, C, M>
where A: Into<Address>, H: SystemHandler<C, M> + Send + 'static,

Add a new handler to the builder, re-addressing the previous handler’s “default” route to this one

source

pub fn chain_for<A, H>( &mut self, rule: impl Into<String>, addr: A, prev_id: impl Into<String>, id: impl Into<String>, handler: H ) -> HandlerBuilder<'_, C, M>
where A: Into<Address>, H: SystemHandler<C, M> + Send + 'static,

Add a new handler to the builder, re-addressing the previous handler’s named route to this one

source

pub fn readdress(&mut self, fin_addr: &Address)

Re-address every system handler in order to clone it

When initialising a worker system builder you setup handlers and routes between them. However when cloning the worker system all addresses need to be re-addressed in order to allow a second instance of every address to exist on the same node.

This problem may be solved by having scoped addresses in the future.

This function assigns a new address to every handler and then changes routes that point to the old addresses. Any route that is not in the internal set (i.e. the fin address routes) are replaced with the externally provided fin-address.

source

pub async fn finalise(self, ctx: &mut C) -> Result<WorkerSystem<C, M>>

Create a WorkerSystem and pre-initialise every SystemHandler

Trait Implementations§

source§

impl<C, M> Clone for SystemBuilder<C, M>
where C: Send + 'static, M: Message,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C, M> Default for SystemBuilder<C, M>
where C: Send + 'static, M: Message,

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C, M> !RefUnwindSafe for SystemBuilder<C, M>

§

impl<C, M> Send for SystemBuilder<C, M>

§

impl<C, M> !Sync for SystemBuilder<C, M>

§

impl<C, M> Unpin for SystemBuilder<C, M>

§

impl<C, M> !UnwindSafe for SystemBuilder<C, M>

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<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

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