Trait foca::Runtime

source ·
pub trait Runtime<T>
where T: Identity,
{ // Required methods fn notify(&mut self, notification: Notification<T>); fn send_to(&mut self, to: T, data: &[u8]); fn submit_after(&mut self, event: Timer<T>, after: Duration); }
Expand description

A Runtime is Foca’s gateway to the real world: here is where implementations decide how to interact with the network, the hardware timer and the user.

Implementations may react directly to it for a fully synchronous behavior or accumulate-then-drain when dispatching via fancier mechanisms like async.

Required Methods§

source

fn notify(&mut self, notification: Notification<T>)

Whenever something changes Foca’s state significantly a notification is emitted.

It’s the best mechanism to watch for membership changes and allows implementors to keep track of the cluster state without having direct access to the running Foca instance.

Implementations may completely disregard this if desired.

source

fn send_to(&mut self, to: T, data: &[u8])

This is how Foca connects to an actual transport.

Implementations are responsible for the actual delivery.

source

fn submit_after(&mut self, event: Timer<T>, after: Duration)

Request to schedule the delivery of a given event after a specified duration.

Implementations MUST ensure that every event is delivered. Foca is very tolerant to delays, but non-delivery will cause errors.

Implementations on Foreign Types§

source§

impl<T, R> Runtime<T> for &mut R
where T: Identity, R: Runtime<T>,

source§

fn notify(&mut self, notification: Notification<T>)

source§

fn send_to(&mut self, to: T, data: &[u8])

source§

fn submit_after(&mut self, event: Timer<T>, after: Duration)

Implementors§