pub struct PeerRequestQueue { /* private fields */ }Expand description
Implementations§
Source§impl PeerRequestQueue
impl PeerRequestQueue
Sourcepub fn enqueue(
&mut self,
peer_id: &str,
priority: RequestPriority,
payload_size: u64,
) -> u64
pub fn enqueue( &mut self, peer_id: &str, priority: RequestPriority, payload_size: u64, ) -> u64
Enqueue a new request and return its unique identifier.
Sourcepub fn dequeue(&mut self) -> Option<PeerRequest>
pub fn dequeue(&mut self) -> Option<PeerRequest>
Pop the highest-priority request (FIFO within each level).
Returns None when every sub-queue is empty.
Sourcepub fn peek(&self) -> Option<&PeerRequest>
pub fn peek(&self) -> Option<&PeerRequest>
Peek at the highest-priority request without removing it.
Sourcepub fn drain_priority(&mut self, priority: RequestPriority) -> Vec<PeerRequest>
pub fn drain_priority(&mut self, priority: RequestPriority) -> Vec<PeerRequest>
Remove and return all requests at the given priority level.
Sourcepub fn cancel(&mut self, request_id: u64) -> bool
pub fn cancel(&mut self, request_id: u64) -> bool
Cancel a specific request by its unique identifier.
Returns true if the request was found and removed.
Sourcepub fn count_by_priority(&self, priority: RequestPriority) -> usize
pub fn count_by_priority(&self, priority: RequestPriority) -> usize
Number of pending requests at the given priority level.
Sourcepub fn total_payload_bytes(&self) -> u64
pub fn total_payload_bytes(&self) -> u64
Sum of payload_size across all pending requests.
Sourcepub fn stats(&self) -> PriorityQueueStats
pub fn stats(&self) -> PriorityQueueStats
Snapshot of current queue statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerRequestQueue
impl RefUnwindSafe for PeerRequestQueue
impl Send for PeerRequestQueue
impl Sync for PeerRequestQueue
impl Unpin for PeerRequestQueue
impl UnsafeUnpin for PeerRequestQueue
impl UnwindSafe for PeerRequestQueue
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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