Skip to main content

TimedWindows

Struct TimedWindows 

Source
pub struct TimedWindows<const N: usize> { /* private fields */ }
Expand description

The open Timed transaction windows of a node.

N is how many may be open at once. One per concurrent administrator is generous: a Timed transaction’s whole life is one round trip plus a timeout the client chose, and a client with two open at once on the same session is already misbehaving.

Implementations§

Source§

impl<const N: usize> TimedWindows<N>

Source

pub const fn new() -> Self

A table with nothing open.

Source

pub fn open( &mut self, session: Option<SessionId>, exchange: ExchangeId, timeout_ms: u16, sent_at: Instant, ) -> Result<()>

Opens a window, as §8.7.4.3 requires after answering a Timed Request.

sent_at is when the SUCCESS status response went out, not when the Timed Request arrived: §8.7.4, “the Timeout interval SHALL start when the Status Response action acknowledging the Timed Request action with a success code is sent”.

A second Timed Request on the same exchange replaces the first: one transaction, one deadline.

§Errors

ErrorCode::NoSpace when every slot holds a live window — §8.7.3.2’s BUSY case, so a caller answers Status::Busy rather than pretending the window opened.

Source

pub fn check( &mut self, session: Option<SessionId>, exchange: ExchangeId, timed_request: bool, now: Instant, ) -> Result<bool, Status>

Applies §8.7.3.2 and §8.8.2.3’s timed rules to an arriving Write or Invoke Request.

timed_request is the request’s own TimedRequest flag. Returns what InteractionContext::timed must be set to, or the status the interaction terminates with.

The window is consumed either way — every outcome here terminates the transaction, and a window that survived would let one Timed Request pay for a second request later.

§Errors

Status::Timeout when the window expired, Status::TimedRequestMismatch when the flag and the window disagree.

Source

pub fn close(&mut self, session: Option<SessionId>, exchange: ExchangeId)

Closes the window on an exchange without applying any rule.

For the case where the exchange itself ends — the session closed, the client vanished — rather than a request arriving on it.

Source

pub fn close_session(&mut self, session: Option<SessionId>)

Drops every window of a session, for when the session closes.

Source

pub fn reap(&mut self, now: Instant) -> usize

Drops every window whose deadline has passed, returning how many went.

Optional: TimedWindows::open already reclaims expired slots when it needs one. A window dropped here can no longer produce Status::Timeout, only Status::TimedRequestMismatch, since the evidence that there was a window is gone.

Source

pub fn len(&self) -> usize

How many windows are held, expired or not.

Source

pub fn is_empty(&self) -> bool

Whether no window is held.

Source

pub fn next_deadline(&self) -> Option<Instant>

The earliest deadline, for a caller that wants to schedule a reap.

Trait Implementations§

Source§

impl<const N: usize> Clone for TimedWindows<N>

Source§

fn clone(&self) -> Self

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<const N: usize> Debug for TimedWindows<N>

Source§

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

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

impl<const N: usize> Default for TimedWindows<N>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const N: usize> Forget for TimedWindows<N>

§

impl<const N: usize> Freeze for TimedWindows<N>
where [Option<Window>; N]: Freeze,

§

impl<const N: usize> Move for TimedWindows<N>

§

impl<const N: usize> RefUnwindSafe for TimedWindows<N>
where [Option<Window>; N]: RefUnwindSafe,

§

impl<const N: usize> Send for TimedWindows<N>
where [Option<Window>; N]: Send,

§

impl<const N: usize> Sync for TimedWindows<N>
where [Option<Window>; N]: Sync,

§

impl<const N: usize> Unpin for TimedWindows<N>
where [Option<Window>; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for TimedWindows<N>
where [Option<Window>; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for TimedWindows<N>
where [Option<Window>; N]: 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.