Struct mixnet::request_manager::RequestManager

source ·
pub struct RequestManager<R> { /* private fields */ }
Expand description

Request manager state. The user is responsible for calling update_session_status, process_post_queues, and pop_next_retry at the appropriate times to make progress.

Implementations§

source§

impl<C, R: Request<Context = C>> RequestManager<R>

source

pub fn new(config: Config) -> Self

Create a new RequestManager with the given configuration.

source

pub fn update_session_status<X>( &mut self, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, )

Update the current session index and phase. This should be called after Mixnet::set_session_status. This may post messages to mixnet.

source

pub fn has_space(&self) -> bool

Returns true iff there is space for another request.

source

pub fn insert<X>( &mut self, request: R, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, )

Insert a request. This should only be called if there is space (see has_space). This may post messages to mixnet.

A request is only removed when:

source

pub fn remove(&mut self, message_id: &MessageId) -> Option<R>

Remove a request. Typically this would be called when a reply is received. Returns None if there is no request with the given message ID.

source

pub fn process_post_queues<X>( &mut self, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, )

Attempt to post messages from the internal post queues to mixnet. This should be called when the SPACE_IN_AUTHORED_PACKET_QUEUE event fires.

source

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

Returns the next instant at which pop_next_retry should be called.

source

pub fn pop_next_retry<X>( &mut self, mixnet: &mut Mixnet<X>, ns: &dyn NetworkStatus, context: &C, ) -> bool

Pop the next request from the internal retry queue. This should be called whenever the deadline returned by next_retry_deadline is reached. This may post messages to mixnet. Returns false if the internal retry queue is empty.

source

pub fn next_retry_deadline_changed(&mut self) -> bool

Returns true if the next retry deadline (see next_retry_deadline) has changed since the last call.

Auto Trait Implementations§

§

impl<R> Freeze for RequestManager<R>

§

impl<R> RefUnwindSafe for RequestManager<R>
where R: RefUnwindSafe,

§

impl<R> Send for RequestManager<R>
where R: Send,

§

impl<R> Sync for RequestManager<R>
where R: Sync,

§

impl<R> Unpin for RequestManager<R>
where R: Unpin,

§

impl<R> UnwindSafe for RequestManager<R>
where R: 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> 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V