Skip to main content

Embedded

Struct Embedded 

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

A broker running on a thread of this process.

Implementations§

Source§

impl Embedded

Source

pub fn open(listing: impl IntoIterator<Item = (Host, Path)>) -> Self

A broker that knows where these hosts are.

The listing is fixed when the broker opens and the thread owns it, which is why there is no lock around it and no way for two threads to disagree about where w1 is. A host that has to be added is a broker that has to be opened.

Source

pub fn served_by(desk: impl FnMut(Ask) -> Reply + Send + 'static) -> Self

A broker whose answers come from desk.

Public for one reason, and a present one: the worst thing this type can do is turn a panic into a hang, and there is no way to test that a desk which fails is reported as a failure without being able to stand one up.

Source

pub fn greet(&self) -> Result<(), Unanswered>

Opens the session, if it was not open.

Idempotent on purpose: whoever needs a rendezvous calls this first and does not have to know whether somebody else already did. A refusal is a refusal of the session, which is why it is not swallowed and retried.

Source

pub fn ask(&self, ask: &Ask) -> Result<Reply, Unanswered>

Says something and waits for the answer.

Every message has exactly one answer except Ask::Done, which has none — use Embedded::done for that one. Asking it here is refused rather than waited on, because the alternative is the hang this type is built not to have.

Source

pub fn done(&self, host: &Host) -> Result<(), Unanswered>

Lets a rendezvous go. Nothing answers, and nothing is waited for.

An embedded broker holds nothing, so nothing is released. It is sent anyway because the same client code talks to a broker that does hold things.

Trait Implementations§

Source§

impl Drop for Embedded

Source§

fn drop(&mut self)

Lets the channel go, then waits for the thread. In that order: the thread’s loop ends when the last sender is dropped, so joining first would be waiting for something that is waiting for us.

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

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.