pub struct RequestCorrelator<K: Copy, const N: usize> { /* private fields */ }Expand description
A fixed table of the requests a client has in flight, each keyed by the
sequence id the backend assigned and carrying a caller-chosen K (()
for a plain service client, the GoalUuid for an action sub-client).
See the module docs for the rule it applies.
Implementations§
Source§impl<K: Copy, const N: usize> RequestCorrelator<K, N>
impl<K: Copy, const N: usize> RequestCorrelator<K, N>
Sourcepub fn can_send(&self) -> Result<(), SendRefusal>
pub fn can_send(&self) -> Result<(), SendRefusal>
Whether a new request may be SENT now. Ask this before the send, so a refused request never reaches the wire.
Sourcepub fn insert(&mut self, seq: i64, key: K) -> Result<(), SendRefusal>
pub fn insert(&mut self, seq: i64, key: K) -> Result<(), SendRefusal>
Record a request the backend accepted. Call after a send
can_send allowed; Err(Full) if the table is full
anyway (nothing is recorded then).
Sourcepub fn insert_evicting(&mut self, seq: i64, key: K)
pub fn insert_evicting(&mut self, seq: i64, key: K)
Record a request, evicting the OLDEST pending one when the table is
full. For a RE-SEND of one logical call (rclc_client_call’s
discovery-race retry), where every generation answers the same
question and the oldest is the least likely to still be answered.
Sourcepub fn remove(&mut self, seq: i64) -> bool
pub fn remove(&mut self, seq: i64) -> bool
Forget a pending request (cancelled / removed). Its reply, if it still
comes, is dropped. true if it was pending.
Sourcepub fn remove_key(&mut self, key: &K) -> boolwhere
K: PartialEq,
pub fn remove_key(&mut self, key: &K) -> boolwhere
K: PartialEq,
Forget ONE pending request carrying key — the oldest — as
remove does by id. For a caller that knows what a
request was ABOUT but not the id the backend gave it: an action
client’s future is keyed by its goal, so when the last owner of a
goal’s request lets go before the reply, this frees the slot the
request held. Its reply, if it still comes, is dropped.
true if one was pending.
Trait Implementations§
Source§impl<K: Clone + Copy, const N: usize> Clone for RequestCorrelator<K, N>
impl<K: Clone + Copy, const N: usize> Clone for RequestCorrelator<K, N>
Source§fn clone(&self) -> RequestCorrelator<K, N>
fn clone(&self) -> RequestCorrelator<K, N>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<K: Copy + Copy, const N: usize> Copy for RequestCorrelator<K, N>
Source§impl<K: Copy, const N: usize> ReplyMatcher for RequestCorrelator<K, N>
impl<K: Copy, const N: usize> ReplyMatcher for RequestCorrelator<K, N>
Source§fn match_reply(&mut self, reply_seq: i64) -> bool
fn match_reply(&mut self, reply_seq: i64) -> bool
true if reply_seq answers a pending request (which is then retired),
false if the reply is stale and must be dropped.