Skip to main content

Link

Struct Link 

Source
pub struct Link { /* private fields */ }
Expand description

The delivery state of one peer: the unacknowledged messages, the current connection, and the acknowledgements received. It outlives connections, so a reconnect sends every pending message again. It is Send + Sync; the I/O lives in the connection code, which hands the link a channel of outgoing frame texts on connect.

Implementations§

Source

pub fn new() -> Self

A link with no connection yet.

Source

pub fn offer(&self, env: Envelope) -> Offer

Offers env for delivery: sends it if connected and not yet sent on this connection, and reports whether the peer has acknowledged it. Offering the same message id again is how the outbox retries; it is sent once per connection.

Source

pub fn watch(&self, id: &str)

Asks to hear of the acknowledgement (or refusal) of message id through Link::take_settled instead of a later Link::offer.

Source

pub fn take_settled(&self) -> Vec<(String, Result<(), String>)>

The watched messages acknowledged or failed since the last call.

Source

pub fn is_pending(&self, id: &str) -> bool

Whether message id waits for an acknowledgement.

Source

pub fn pending_len(&self) -> usize

The number of messages waiting for an acknowledgement.

Source

pub fn connected(&self, generation: u64, tx: UnboundedSender<String>)

A connection with number generation is open (and accepted): its writer takes the frame texts sent into tx. Every pending message is sent again, oldest first, and a refusal is forgotten.

Source

pub fn disconnected(&self, generation: u64)

The connection generation closed (a later connection is left alone).

Source

pub fn is_connected(&self) -> bool

Whether a connection is open.

Source

pub fn ack(&self, id: &str)

Sends an acknowledgement of message id on the current connection.

Source

pub fn send_frame(&self, f: &Frame) -> bool

Sends a frame on the current connection; false when there is none.

Source

pub fn refused(&self, reason: &str) -> Vec<String>

The credential was refused: watched pending messages fail, the others are dropped from the link (the outbox offers them again and learns of the refusal then). The refusal holds until the next accepted connection.

Source

pub fn refusal(&self) -> Option<String>

Whether the peer refused the credential (and no connection was accepted since).

Source

pub fn learn_route(&self, iri: &str)

Learns that actor iri is reachable through this link (the origin of a message it sent).

Source

pub fn routes_to(&self, iri: &str) -> bool

Whether actor iri is known to be reachable through this link.

Source

pub fn receive(&self, text: &str) -> Result<Inbound, String>

Handles one received frame text.

§Errors

A message for text that is not a frame.

Trait Implementations§

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

fn default() -> Self

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

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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