Skip to content

Commit 9b2d176

Browse files
Adds "OwnedRoute".
It is just a copy of Route without any lifetimes.
1 parent 5e275eb commit 9b2d176

File tree

2 files changed

+295
-106
lines changed

2 files changed

+295
-106
lines changed

src/http/ratelimiting.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
//!
3636
//! [Taken from]: https://discord.com/developers/docs/topics/rate-limits#rate-limits
3737
38-
use std::borrow::Cow;
3938
use std::fmt;
4039
use std::str::{self, FromStr};
4140
use std::time::SystemTime;
@@ -47,6 +46,7 @@ use tokio::sync::Mutex;
4746
use tokio::time::{sleep, Duration};
4847
use tracing::debug;
4948

49+
use super::routing::OwnedRoute;
5050
pub use super::routing::RatelimitingBucket;
5151
use super::{HttpError, LightMethod, Request};
5252
use crate::internal::prelude::*;
@@ -59,7 +59,7 @@ pub struct RatelimitInfo {
5959
pub timeout: std::time::Duration,
6060
pub limit: i64,
6161
pub method: LightMethod,
62-
pub path: Cow<'static, str>,
62+
pub route: OwnedRoute,
6363
pub global: bool,
6464
}
6565

@@ -228,7 +228,7 @@ impl Ratelimiter {
228228
timeout: Duration::from_secs_f64(retry_after),
229229
limit: 50,
230230
method: req.method,
231-
path: req.route.path(),
231+
route: req.route.upgrade_to_fully_owned_route(),
232232
global: true,
233233
});
234234
sleep(Duration::from_secs_f64(retry_after)).await;
@@ -322,7 +322,7 @@ impl Ratelimit {
322322
timeout: delay,
323323
limit: self.limit,
324324
method: req.method,
325-
path: req.route.path(),
325+
route: req.route.upgrade_to_fully_owned_route(),
326326
global: false,
327327
});
328328

@@ -380,7 +380,7 @@ impl Ratelimit {
380380
timeout: Duration::from_secs_f64(retry_after),
381381
limit: self.limit,
382382
method: req.method,
383-
path: req.route.path(),
383+
route: req.route.upgrade_to_fully_owned_route(),
384384
global: false,
385385
});
386386

0 commit comments

Comments
 (0)