sponsorblock-mirror/src/structs.rs

40 lines
950 B
Rust
Raw Normal View History

2022-10-26 03:40:56 +05:30
use std::cmp::Ordering;
2022-10-22 17:58:40 +05:30
use serde::{Deserialize, Serialize};
2022-10-25 14:01:12 +05:30
#[derive(Serialize, Deserialize, Clone, Debug)]
2022-10-22 17:58:40 +05:30
pub struct Sponsor {
pub hash: String,
2022-10-23 23:33:39 +05:30
#[serde(rename = "videoID")]
2022-10-22 17:58:40 +05:30
pub video_id: String,
pub segments: Vec<Segment>,
}
2022-10-25 14:01:12 +05:30
#[derive(Serialize, Deserialize, Clone, Debug)]
2022-10-22 17:58:40 +05:30
pub struct Segment {
2022-10-23 23:33:39 +05:30
#[serde(rename = "UUID")]
2022-10-22 17:58:40 +05:30
pub uuid: String,
2022-10-23 23:33:39 +05:30
#[serde(rename = "actionType")]
2022-10-22 17:58:40 +05:30
pub action_type: String,
pub category: String,
pub description: String,
pub locked: i32,
pub segment: Vec<f32>,
2022-10-23 23:33:39 +05:30
#[serde(rename = "userID")]
2022-10-22 17:58:40 +05:30
pub user_id: String,
2022-10-23 23:33:39 +05:30
#[serde(rename = "videoDuration")]
2022-10-22 17:58:40 +05:30
pub video_duration: f32,
pub votes: i32,
}
2022-10-25 14:01:12 +05:30
impl PartialEq for Segment {
fn eq(&self, other: &Self) -> bool {
self.uuid == other.uuid
}
}
2022-10-26 03:40:56 +05:30
impl PartialOrd for Segment {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.segment[0].partial_cmp(&other.segment[0])
}
}