pub struct Embedded { /* private fields */ }Expand description
A broker running on a thread of this process.
Implementations§
Source§impl Embedded
impl Embedded
Sourcepub fn open(listing: impl IntoIterator<Item = (Host, Path)>) -> Self
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.
Sourcepub fn served_by(desk: impl FnMut(Ask) -> Reply + Send + 'static) -> Self
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.
Sourcepub fn greet(&self) -> Result<(), Unanswered>
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.
Sourcepub fn ask(&self, ask: &Ask) -> Result<Reply, Unanswered>
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.