pub struct InMemoryQueue { /* private fields */ }
Expand description
Memory based Queue
implementation backed by an efficient background task.
InMemoryQueue::update
allows for dynamically changing the queue’s
settings.
Cloning the queue is cheap and just increments a reference counter.
Note: A max_concurrency
of 0
processes all requests instantly,
effectively disabling the queue.
Implementations§
Source§impl InMemoryQueue
impl InMemoryQueue
Sourcepub fn new(
max_concurrency: u16,
remaining: u32,
reset_after: Duration,
total: u32,
) -> Self
pub fn new( max_concurrency: u16, remaining: u32, reset_after: Duration, total: u32, ) -> Self
Sourcepub fn update(
&self,
max_concurrency: u16,
remaining: u32,
reset_after: Duration,
total: u32,
)
pub fn update( &self, max_concurrency: u16, remaining: u32, reset_after: Duration, total: u32, )
Update the queue with new info from the Get Gateway Bot endpoint.
May be regularly called as the bot joins/leaves guilds.
§Example
use std::time::Duration;
use twilight_http::Client;
let client = Client::new(token);
let session = client
.gateway()
.authed()
.await?
.model()
.await?
.session_start_limit;
queue.update(
session.max_concurrency,
session.remaining,
Duration::from_millis(session.reset_after),
session.total,
);
§Panics
Panics if total
< remaining
.
Trait Implementations§
Source§impl Clone for InMemoryQueue
impl Clone for InMemoryQueue
Source§fn clone(&self) -> InMemoryQueue
fn clone(&self) -> InMemoryQueue
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for InMemoryQueue
impl Debug for InMemoryQueue
Source§impl Default for InMemoryQueue
impl Default for InMemoryQueue
Source§fn default() -> Self
fn default() -> Self
Creates a new InMemoryQueue
with Discord’s default settings.
Currently these are:
max_concurrency
: 1remaining
: 1000reset_after
:LIMIT_PERIOD
total
: 1000.
Auto Trait Implementations§
impl Freeze for InMemoryQueue
impl RefUnwindSafe for InMemoryQueue
impl Send for InMemoryQueue
impl Sync for InMemoryQueue
impl Unpin for InMemoryQueue
impl UnwindSafe for InMemoryQueue
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
Mutably borrows from an owned value. Read more