Skip to content

Commit 7a0e90f

Browse files
authored
fix(validate, http): use smaller and unsigned integer for get-pins limit (#2477)
1 parent 736305a commit 7a0e90f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

twilight-http/src/request/channel/get_pins.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use twilight_validate::request::{ValidationError, pin_limit as validate_pin_limi
1313

1414
pub struct GetPinsQueryFields {
1515
before: Option<Timestamp>,
16-
limit: Option<i32>,
16+
limit: Option<u16>,
1717
}
1818

1919
/// Get the pins of a channel.
@@ -54,7 +54,7 @@ impl<'a> GetPins<'a> {
5454
/// [docs]
5555
///
5656
/// [docs]: https://discord.com/developers/docs/resources/message#get-channel-pins-query-string-params
57-
pub fn limit(mut self, limit: i32) -> Self {
57+
pub fn limit(mut self, limit: u16) -> Self {
5858
self.fields = self.fields.and_then(|mut fields| {
5959
validate_pin_limit(limit)?;
6060

twilight-http/src/routing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ pub enum Route<'a> {
802802
/// The ID of the channel.
803803
channel_id: u64,
804804
/// Optionally the limit of pins to show in the response. (1-50) (default: 50)
805-
limit: Option<i32>,
805+
limit: Option<u16>,
806806
/// Optionally the timestamp as a filter to only show pins before the provided timestamp.
807807
before: Option<String>,
808808
},

twilight-validate/src/request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ pub const NICKNAME_LIMIT_MAX: usize = 32;
129129
pub const NICKNAME_LIMIT_MIN: usize = 1;
130130

131131
/// Maximum pin limit.
132-
pub const PIN_LIMIT_MAX: i32 = 50;
132+
pub const PIN_LIMIT_MAX: u16 = 50;
133133

134134
/// Minimum pin limit.
135-
pub const PIN_LIMIT_MIN: i32 = 1;
135+
pub const PIN_LIMIT_MIN: u16 = 1;
136136

137137
/// Maximum length of a scheduled event's description.
138138
pub const SCHEDULED_EVENT_DESCRIPTION_MAX: usize = 1000;
@@ -714,7 +714,7 @@ pub enum ValidationErrorType {
714714
/// Provided pin limit was invalid.
715715
Pin {
716716
/// Invalid limit.
717-
limit: i32,
717+
limit: u16,
718718
},
719719
/// Scheduled event description is invalid.
720720
ScheduledEventDescription {
@@ -1510,7 +1510,7 @@ pub fn nickname(nickname: impl AsRef<str>) -> Result<(), ValidationError> {
15101510
///
15111511
/// [`Pin`]: ValidationErrorType::Pin
15121512
/// [pin limit]: https://discord.com/developers/docs/resources/message#get-channel-pins-query-string-params
1513-
pub fn pin_limit(limit: i32) -> Result<(), ValidationError> {
1513+
pub fn pin_limit(limit: u16) -> Result<(), ValidationError> {
15141514
if (PIN_LIMIT_MIN..=PIN_LIMIT_MAX).contains(&limit) {
15151515
Ok(())
15161516
} else {

0 commit comments

Comments
 (0)