pub struct ExchangeTable { /* private fields */ }Expand description
The table of server-initiated requests a session is waiting on.
Cheap to clone: a session’s exchange and the router answering its requests are two handles to one table, never two tables. That matters because a request and the answer completing it must land on the same session, and sharing is what makes that structural rather than a convention.
Implementations§
Source§impl ExchangeTable
impl ExchangeTable
Sourcepub fn new() -> Self
pub fn new() -> Self
A table with nothing in flight and nothing reading the tail.
The unreadable default is the safe one. A session that has not said it is served as a stream has not established that anything is reading, so the honest answer to “may I ask the peer a question?” is no.
Sourcepub fn readable() -> Self
pub fn readable() -> Self
A table whose session’s tail this server drains.
Called once, when a session is opened against a server configured to
answer with an event stream. Every later Self::new on the same
handle — and there are none, this is the only constructor that sets it
— inherits the answer.
Sourcepub fn is_readable(&self) -> bool
pub fn is_readable(&self) -> bool
Whether a server-initiated request can be asked and answered here.
Sourcepub fn resolve(&self, id: i64, answer: Answer) -> bool
pub fn resolve(&self, id: i64, answer: Answer) -> bool
Hands a peer’s answer to whoever is waiting for id.
false when the id is unknown — a reply to a request that already
completed, was refused, or never existed. All three are the same from
here and all three are correctly dropped.
Sourcepub fn outstanding(&self) -> usize
pub fn outstanding(&self) -> usize
How many requests are outstanding.
For a diagnostics line and a test. Taking the lock is why this is not on any per-frame path.