froxy/scraper/src/types.rs

128 lines
2.7 KiB
Rust
Raw Normal View History

use smol_str::SmolStr;
2026-02-06 23:24:21 +01:00
#[non_exhaustive]
#[derive(Debug, Clone, Default, Eq, PartialEq)]
pub enum ClusterLocationStatus {
#[doc(alias = "red")]
Dead,
#[doc(alias = "orange")]
Damaged,
#[doc(alias = "good")]
#[default]
Ok,
}
#[derive(Debug, Clone, Default)]
pub enum Relation {
CloseFriend,
Friend,
Pooled,
Me,
Focus,
#[default]
None,
}
#[derive(Debug, Clone, Default)]
pub enum ClusterLocationData {
User {
login: smol_str::SmolStr,
image: Option<url::Url>,
relation: Relation,
},
Normal {
status: ClusterLocationStatus,
},
#[default]
Empty,
}
#[derive(Debug, Clone)]
pub struct ClusterLocation {
pub location: smol_str::SmolStr,
pub data: ClusterLocationData,
}
#[derive(Debug, Clone)]
pub struct CluserInformation {
pub cluster_name: smol_str::SmolStr,
pub locations: Vec<ClusterLocation>,
}
#[derive(Debug, Clone)]
pub struct Friend {
pub login: SmolStr,
pub image: Option<String>,
pub position: Option<SmolStr>,
pub last_active: Option<SmolStr>,
}
#[derive(Debug, Clone)]
pub struct Friends {
pub friends: Vec<Friend>,
}
2026-02-08 17:01:27 +01:00
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
#[serde(untagged)]
pub(crate) enum IsFriend {
U32(u32),
Bool(bool),
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub(crate) struct ProfileRaw {
pub(crate) admin: bool,
pub(crate) active: Option<SmolStr>,
pub(crate) campus: u64,
pub(crate) id: u64,
pub(crate) userid: Option<u64>,
pub(crate) image: String,
pub(crate) image_medium: String,
pub(crate) is_friend: IsFriend,
pub(crate) lang: SmolStr,
pub(crate) name: SmolStr,
pub(crate) pool: Option<SmolStr>,
pub(crate) position: Option<SmolStr>,
pub(crate) recit: Option<String>,
pub(crate) website: Option<String>,
pub(crate) discord: Option<String>,
pub(crate) github: Option<String>,
}
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
pub struct Profile {
pub admin: bool,
pub campus: u64,
pub id: u64,
pub userid: Option<u64>,
pub pool: Option<SmolStr>,
pub image: String,
pub image_medium: String,
pub is_friend: bool,
pub lang: SmolStr,
pub name: SmolStr,
pub position: Option<SmolStr>,
pub active: Option<SmolStr>,
pub website: Option<String>,
pub recit: Option<String>,
pub discord: Option<String>,
pub github: Option<String>,
}
2026-02-09 00:01:07 +01:00
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, Hash)]
#[serde(tag = "type")]
pub enum Search {
#[serde(rename = "project")]
Project { v: SmolStr, s: SmolStr },
#[serde(rename = "user")]
User { v: SmolStr, s: SmolStr },
}