Skip to content

Commit 9b7a73a

Browse files
Adds "OwnedRoute".
It is just a copy of Route without any lifetimes.
1 parent 7da8e2a commit 9b7a73a

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;
@@ -49,6 +48,7 @@ use tracing::debug;
4948
#[cfg(feature = "tracing_instrument")]
5049
use tracing::instrument;
5150

51+
use super::routing::OwnedRoute;
5252
pub use super::routing::RatelimitingBucket;
5353
use super::{HttpError, LightMethod, Request};
5454
use crate::internal::prelude::*;
@@ -61,7 +61,7 @@ pub struct RatelimitInfo {
6161
pub timeout: std::time::Duration,
6262
pub limit: i64,
6363
pub method: LightMethod,
64-
pub path: Cow<'static, str>,
64+
pub route: OwnedRoute,
6565
pub global: bool,
6666
}
6767

@@ -230,7 +230,7 @@ impl Ratelimiter {
230230
timeout: Duration::from_secs_f64(retry_after),
231231
limit: 50,
232232
method: req.method,
233-
path: req.route.path(),
233+
route: req.route.upgrade_to_fully_owned_route(),
234234
global: true,
235235
});
236236
sleep(Duration::from_secs_f64(retry_after)).await;
@@ -324,7 +324,7 @@ impl Ratelimit {
324324
timeout: delay,
325325
limit: self.limit,
326326
method: req.method,
327-
path: req.route.path(),
327+
route: req.route.upgrade_to_fully_owned_route(),
328328
global: false,
329329
});
330330

@@ -382,7 +382,7 @@ impl Ratelimit {
382382
timeout: Duration::from_secs_f64(retry_after),
383383
limit: self.limit,
384384
method: req.method,
385-
path: req.route.path(),
385+
route: req.route.upgrade_to_fully_owned_route(),
386386
global: false,
387387
});
388388

0 commit comments

Comments
 (0)