diff options
author | David Blajda <blajda@hotmail.com> | 2018-12-24 23:08:26 +0000 |
---|---|---|
committer | David Blajda <blajda@hotmail.com> | 2018-12-24 23:08:26 +0000 |
commit | 2f1682162174f5fee4f4297f616e8f66b7c70dca (patch) | |
tree | dad5dff552442b1801553c9944a1967121e667cb /src/helix/models.rs | |
parent | 298806448db4a4e74306ec648bfc0e43a76c6bc3 (diff) |
Fix lifetimes on ratelimit trait
Diffstat (limited to 'src/helix/models.rs')
-rw-r--r-- | src/helix/models.rs | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/helix/models.rs b/src/helix/models.rs index 86b7560..bdb8438 100644 --- a/src/helix/models.rs +++ b/src/helix/models.rs @@ -5,14 +5,29 @@ use url::Url; use chrono::{DateTime, Utc}; use super::types::{UserId, VideoId, ChannelId}; +pub trait PaginationTrait { + fn cursor<'a>(&'a self) -> &'a Option<Cursor>; + fn set_request(&mut self); +} + #[derive(Debug, Deserialize)] pub struct DataContainer<T> { pub data: Vec<T> } -#[derive(Debug, Deserialize)] -pub struct Cursor { - cursor: String +impl<T> PaginationTrait for DataContainer<T> { + fn cursor<'a>(&'a self) -> &'a Option<Cursor> { &None } + fn set_request(&mut self) {} +} + +impl<T> PaginationTrait for PaginationContainer<T> { + fn cursor<'a>(&'a self) -> &'a Option<Cursor> { &self.pagination } + fn set_request(&mut self) {} +} + +impl PaginationTrait for Credentials { + fn cursor<'a>(&'a self) -> &'a Option<Cursor> { &None } + fn set_request(&mut self) {} } #[derive(Debug, Deserialize)] @@ -22,6 +37,21 @@ pub struct PaginationContainer<T> { } #[derive(Debug, Deserialize)] +pub struct Cursor { + cursor: String +} + +#[derive(Debug, Deserialize)] +pub struct Credentials { + pub access_token: String, + pub refresh_token: Option<String>, + pub expires_in: u32, + pub scope: Option<Vec<String>>, + pub token_type: String, +} + + +#[derive(Debug, Deserialize)] pub struct Video { pub id: VideoId, pub user_id: UserId, @@ -80,13 +110,3 @@ pub struct Clip { pub thumbnail_url: Url, pub view_count: i32, } - - -#[derive(Debug, Deserialize)] -pub struct Credentials { - pub access_token: String, - pub refresh_token: Option<String>, - pub expires_in: u32, - pub scope: Option<Vec<String>>, - pub token_type: String, -} |