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>
impl<C, R: Request<Context = C>> RequestManager<R>
sourcepub fn update_session_status<X>(
&mut self,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
)
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
.
sourcepub fn insert<X>(
&mut self,
request: R,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
)
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:
remove
is called with the corresponding message ID. This would typically happen when a reply is received.- An unrecoverable error is encountered while posting to the mixnet. In this case,
Request::handle_post_err
is called. - The retry limit is reached. In this case,
Request::handle_retry_limit_reached
is called.
sourcepub fn remove(&mut self, message_id: &MessageId) -> Option<R>
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.
sourcepub fn process_post_queues<X>(
&mut self,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
)
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.
sourcepub fn next_retry_deadline(&self) -> Option<Instant>
pub fn next_retry_deadline(&self) -> Option<Instant>
Returns the next instant at which pop_next_retry
should be
called.
sourcepub fn pop_next_retry<X>(
&mut self,
mixnet: &mut Mixnet<X>,
ns: &dyn NetworkStatus,
context: &C,
) -> bool
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.
sourcepub fn next_retry_deadline_changed(&mut self) -> bool
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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