#![deny(missing_docs)]
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
use std::ops::Deref;
use std::str::FromStr;
pub mod many_to_many;
pub mod one_to_many;
pub mod one_to_one;
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, Hash)]
pub struct SessionId(String);
impl SessionId {
pub fn new(inner: String) -> Self {
SessionId(inner)
}
pub fn as_str(&self) -> &str {
&self.0
}
pub fn into_inner(self) -> String {
self.0
}
}
impl FromStr for SessionId {
type Err = Box<dyn std::error::Error>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(SessionId(s.to_string()))
}
}
impl Display for SessionId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Hash)]
pub struct UserId(usize);
impl UserId {
pub fn new(inner: usize) -> Self {
UserId(inner)
}
pub fn into_inner(self) -> usize {
self.0
}
}
impl From<usize> for UserId {
fn from(val: usize) -> Self {
UserId(val)
}
}
impl Display for UserId {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl Deref for UserId {
type Target = usize;
fn deref(&self) -> &Self::Target {
&self.0
}
}
pub type IsHost = bool;