Skip to main content

x_rs/
auth.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone)]
4pub enum Auth {
5    Guest { token: String },
6    Cookies(CookieData),
7    None,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct CookieData {
12    pub ct0: String,
13    pub auth_token: String,
14}
15
16impl CookieData {
17    pub fn new(ct0: impl Into<String>, auth_token: impl Into<String>) -> Self {
18        Self {
19            ct0: ct0.into(),
20            auth_token: auth_token.into(),
21        }
22    }
23
24    pub fn to_cookie_string(&self) -> String {
25        format!("ct0={}; auth_token={}", self.ct0, self.auth_token)
26    }
27}