49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
use iris::core::util::HashSet;
|
|
pub use openworm::net::{AccountToken, ServerPerms};
|
|
|
|
pub type UserId = u64;
|
|
pub type MsgId = i128;
|
|
pub type ChannelId = u64;
|
|
pub type ImageId = u64;
|
|
|
|
#[derive(bitcode::Encode, bitcode::Decode)]
|
|
pub struct User {
|
|
pub username: String,
|
|
pub password_hash: String,
|
|
pub pfp: Option<ImageId>,
|
|
pub bio: String,
|
|
pub friends: Friends,
|
|
pub server_perms: ServerPerms,
|
|
}
|
|
|
|
impl User {
|
|
pub fn new(username: String, password_hash: String, perms: ServerPerms) -> Self {
|
|
Self {
|
|
username,
|
|
password_hash,
|
|
bio: String::new(),
|
|
pfp: None,
|
|
friends: Default::default(),
|
|
server_perms: perms,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Default, bitcode::Encode, bitcode::Decode)]
|
|
pub struct Friends {
|
|
pub current: HashSet<UserId>,
|
|
pub outgoing: HashSet<UserId>,
|
|
pub incoming: HashSet<UserId>,
|
|
}
|
|
|
|
#[derive(bitcode::Encode, bitcode::Decode)]
|
|
pub struct Msg {
|
|
pub content: String,
|
|
pub author: UserId,
|
|
}
|
|
|
|
pub struct Channel {
|
|
pub name: String,
|
|
pub desc: String,
|
|
}
|