use racal::FromApiState;
use serde::{Deserialize, Serialize};
use crate::model::UserSession;
mod friends;
pub use friends::*;
mod groups;
pub use groups::*;
mod messages;
pub use messages::*;
mod sessions;
pub use sessions::*;
mod stats;
pub use stats::*;
mod testing;
pub use testing::*;
mod user_sessions;
pub use user_sessions::*;
mod users;
pub use users::*;
pub struct NoAuthentication {}
impl racal::FromApiState<Self> for NoAuthentication {
fn from_state(state: &Self) -> &Self { state }
}
impl racal::FromApiState<Authentication> for NoAuthentication {
fn from_state(_: &Authentication) -> &Self { &Self {} }
}
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Authentication {
pub token: String,
pub user_id: crate::id::User,
}
impl std::fmt::Debug for Authentication {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Authentication")
.field("token", &"*****")
.field("user_id", &self.user_id)
.finish()
}
}
impl FromApiState<Self> for Authentication {
fn from_state(state: &Self) -> &Self { state }
}
impl From<&UserSession> for Authentication {
fn from(user_session: &UserSession) -> Self {
Self {
token: user_session.token.clone(),
user_id: user_session.user_id.clone(),
}
}
}