Skip to content

Commit

Permalink
Adds "OwnedRoute".
Browse files Browse the repository at this point in the history
It is just a copy of Route without any lifetimes.
  • Loading branch information
TheCataliasTNT2k committed Nov 25, 2024
1 parent 5e275eb commit cf3701f
Show file tree
Hide file tree
Showing 2 changed files with 295 additions and 106 deletions.
10 changes: 5 additions & 5 deletions src/http/ratelimiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
//!
//! [Taken from]: https://discord.com/developers/docs/topics/rate-limits#rate-limits
use std::borrow::Cow;
use std::fmt;
use std::str::{self, FromStr};
use std::time::SystemTime;
Expand All @@ -49,6 +48,7 @@ use tracing::debug;

pub use super::routing::RatelimitingBucket;
use super::{HttpError, LightMethod, Request};
use super::routing::OwnedRoute;
use crate::internal::prelude::*;

/// Passed to the [`Ratelimiter::set_ratelimit_callback`] callback. If using Client, that callback
Expand All @@ -59,7 +59,7 @@ pub struct RatelimitInfo {
pub timeout: std::time::Duration,
pub limit: i64,
pub method: LightMethod,
pub path: Cow<'static, str>,
pub route: OwnedRoute,
pub global: bool,
}

Expand Down Expand Up @@ -228,7 +228,7 @@ impl Ratelimiter {
timeout: Duration::from_secs_f64(retry_after),
limit: 50,
method: req.method,
path: req.route.path(),
route: req.route.to_fully_owned_route(),
global: true,
});
sleep(Duration::from_secs_f64(retry_after)).await;
Expand Down Expand Up @@ -322,7 +322,7 @@ impl Ratelimit {
timeout: delay,
limit: self.limit,
method: req.method,
path: req.route.path(),
route: req.route.to_fully_owned_route(),
global: false,
});

Expand Down Expand Up @@ -380,7 +380,7 @@ impl Ratelimit {
timeout: Duration::from_secs_f64(retry_after),
limit: self.limit,
method: req.method,
path: req.route.path(),
route: req.route.to_fully_owned_route(),
global: false,
});

Expand Down
Loading

0 comments on commit cf3701f

Please sign in to comment.