Skip to main content

RequestCorrelator

Struct RequestCorrelator 

Source
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 + Default, const N: usize> RequestCorrelator<K, N>

Source

pub fn new() -> Self

An empty table.

Source§

impl<K: Copy, const N: usize> RequestCorrelator<K, N>

Source

pub const CAPACITY: usize = N

The table’s capacity.

Source

pub fn len(&self) -> usize

Requests currently pending.

Source

pub fn is_empty(&self) -> bool

No request pending.

Source

pub fn dropped(&self) -> u32

Replies dropped so far because no pending request matched them.

Source

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.

Source

pub fn contains(&self, seq: i64) -> bool

Whether seq is pending.

Source

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).

Source

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.

Source

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.

Source

pub fn remove_key(&mut self, key: &K) -> bool
where 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.

Source

pub fn clear(&mut self)

Forget every pending request (the caller abandoned them all — a timed-out blocking call, reset_in_flight). Their replies are dropped.

Source

pub fn resolve(&mut self, reply_seq: i64) -> Option<K>

Match a reply carrying reply_seq to a pending request. Some(key) removes and returns the request it answers; None means the reply is STALE and the caller drops it.

Trait Implementations§

Source§

impl<K: Clone + Copy, const N: usize> Clone for RequestCorrelator<K, N>

Source§

fn clone(&self) -> RequestCorrelator<K, N>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Copy + Copy, const N: usize> Copy for RequestCorrelator<K, N>

Source§

impl<K: Debug + Copy, const N: usize> Debug for RequestCorrelator<K, N>

Source§

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

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

impl<K: Copy + Default, const N: usize> Default for RequestCorrelator<K, N>

Source§

fn default() -> Self

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

impl<K: Copy, const N: usize> ReplyMatcher for RequestCorrelator<K, N>

Source§

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.

Auto Trait Implementations§

§

impl<K, const N: usize> Freeze for RequestCorrelator<K, N>
where K: Freeze,

§

impl<K, const N: usize> RefUnwindSafe for RequestCorrelator<K, N>
where K: RefUnwindSafe,

§

impl<K, const N: usize> Send for RequestCorrelator<K, N>
where K: Send,

§

impl<K, const N: usize> Sync for RequestCorrelator<K, N>
where K: Sync,

§

impl<K, const N: usize> Unpin for RequestCorrelator<K, N>
where K: Unpin,

§

impl<K, const N: usize> UnsafeUnpin for RequestCorrelator<K, N>
where K: UnsafeUnpin,

§

impl<K, const N: usize> UnwindSafe for RequestCorrelator<K, N>
where K: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.