Struct ratman::Router[][src]

pub struct Router { /* fields omitted */ }

Primary async ratman router handle

Make sure you initialise endpoints before calling run, as the set of endpoints gets locked and can’t be changed during runtime.

Implementations

impl Router[src]

pub fn new() -> Arc<Self>[src]

Create a new and empty message router

It’s currently not possible to restore a router from stored state, which means that all routing tables are lost when the router is stopped.

pub async fn add_endpoint(
    &self,
    ep: Arc<impl Endpoint + 'static + Send + Sync>
) -> usize
[src]

Add a new endpoint to this router

An endpoint is defined by the Endpoint trait from the ratman-netmod crate. Once added, an endpoint can’t be removed while in active operation: the router will have to be recreated without the endpoint you wish to remove.

pub async fn del_endpoint(&self, id: usize)[src]

Remove an endpoint from the router by ID

This function is primarily meant for testing purposes, and shouldn’t be used in heavy operation. The required ID is returned by add_endpoint.

pub async fn add_user(&self, id: Identity) -> Result<()>[src]

Add an identity to the local set

Ratman will listen for messages to local identities and offer them up for polling via the Router API.

pub async fn del_user(&self, id: Identity, _keep: bool) -> Result<()>[src]

Remove a local identity, discarding imcomplete messages

Ratman will by default remove all cached frames from the collector. Optionally these frames can be moved into the journal with low priority instead.

pub async fn online(&self, id: Identity) -> Result<()>[src]

Set a user ID as online and broadcast announcements

This function will return an error if the user is already marked as online, or if no such user is known to the router

pub async fn offline(&self, id: Identity) -> Result<()>[src]

Set a user ID as offline and stop broadcasts

pub async fn known(&self, id: Identity) -> Result<()>[src]

Check the local routing table for a user ID

pub async fn discover(&self) -> Identity[src]

Check for newly discovered users on the network

pub fn clock(&self, _cc: ClockCtrl<Tasks>) -> Result<()>[src]

Register a manual clock controller object for internal tasks

pub async fn send(&self, msg: Message) -> Result<()>[src]

Dispatch a message into a network

This operation completes asynchronously, and will yield a result with information about any error that occured while sending.

If you result is an Error::DispatchFaled, that just means that at least one of the packets your Message was sliced into didn’t send properly. As long as you’re not changing the data layout of your payload, or the MsgId, it’s safe to simply retry: the receiving collector/ journals on the way will still be able to associate the frames, and drop the ones that were already dispatched, essentially only filling in the missing gaps.

pub async fn next(&self) -> Message[src]

Get the next available message from the router

Note: This function can’t ever really fail, because it only reads from a set of completed Messages that have been parsed and handled. When an error occurs on an incoming Message, the errors are logged in the diagnostics module, and can be read from there asynchronously.

Auto Trait Implementations

impl !RefUnwindSafe for Router

impl Send for Router

impl Sync for Router

impl Unpin for Router

impl !UnwindSafe for Router

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

impl<T> WithSubscriber for T[src]