summaryrefslogtreecommitdiff
path: root/src/helix/models.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/helix/models.rs')
-rw-r--r--src/helix/models.rs46
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,
-}