Struct ratman::Router [−][src]
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]
&self,
ep: Arc<impl Endpoint + 'static + Send + Sync>
) -> usize
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,