Skip to content

Commit

Permalink
🚚 Move: Prisecter struct to pagination module [#63]
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinrin0413 committed Nov 10, 2024
1 parent dc72638 commit 753dcfd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
31 changes: 31 additions & 0 deletions src/client/param/pagination.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
//! Features for pagination.

use serde::Deserialize;

/// A prisecter.
///
/// A **prisecter** is consisting of three floats.
/// It allows you to continue paginating.
#[derive(Clone, Debug, Deserialize)]
pub struct Prisecter {
/// The primary sort key.
pub pri: f64,
/// The secondary sort key.
pub sec: f64,
/// The tertiary sort key.
pub ter: f64,
}

impl Prisecter {
/// Converts to an array.
///
/// This array can be used as a bound for the next search.
pub fn to_array(&self) -> [f64; 3] {
[self.pri, self.sec, self.ter]
}
}

impl AsRef<Prisecter> for Prisecter {
fn as_ref(&self) -> &Self {
self
}
}

/// A bound to paginate.
#[derive(Clone, Debug)]
pub enum Bound {
Expand Down
30 changes: 1 addition & 29 deletions src/model/leaderboard.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The User Leaderboard models.

use crate::{
client::param::pagination::Prisecter,
model::{
cache::CacheData,
league_rank::Rank,
Expand Down Expand Up @@ -214,35 +215,6 @@ impl AsRef<League> for League {
}
}

/// A prisecter.
///
/// A **prisecter** is consisting of three floats.
/// It allows you to continue paginating.
#[derive(Clone, Debug, Deserialize)]
pub struct Prisecter {
/// The primary sort key.
pub pri: f64,
/// The secondary sort key.
pub sec: f64,
/// The tertiary sort key.
pub ter: f64,
}

impl Prisecter {
/// Converts this prisecter to an array.
///
/// This array can be used as a bound for the next search.
pub fn to_array(&self) -> [f64; 3] {
[self.pri, self.sec, self.ter]
}
}

impl AsRef<Prisecter> for Prisecter {
fn as_ref(&self) -> &Self {
self
}
}

/// The response for the Historical User Leaderboard data.
///
/// An array of historical user blobs fulfilling the search criteria.
Expand Down
3 changes: 2 additions & 1 deletion src/model/summary/record.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! The Record Data models.

use crate::{
model::{leaderboard::Prisecter, league_rank::Rank, user::UserId},
client::param::pagination::Prisecter,
model::{league_rank::Rank, user::UserId},
util::to_unix_ts,
};
use serde::Deserialize;
Expand Down

0 comments on commit 753dcfd

Please sign in to comment.