accounts are now real

This commit is contained in:
2025-12-03 22:51:57 -05:00
parent 4aa22de61b
commit 24bb65bf7b
15 changed files with 679 additions and 163 deletions

View File

@@ -11,24 +11,53 @@ pub const BINCODE_CONFIG: Configuration = bincode::config::standard();
#[derive(Debug, bincode::Encode, bincode::Decode)]
pub enum ClientMsg {
SendMsg(NetMsg),
SendMsg(NetClientMsg),
RequestMsgs,
CreateAccount { username: String, password: String },
Login { username: String, password: String },
}
#[derive(Debug, bincode::Encode, bincode::Decode)]
pub enum ServerMsg {
SendMsg(NetMsg),
LoadMsgs(Vec<NetMsg>),
SendMsg(NetServerMsg),
LoadMsgs(Vec<NetServerMsg>),
Login { username: String },
Error(ServerError),
}
#[derive(Debug, bincode::Encode, bincode::Decode)]
pub enum ServerError {
NotLoggedIn,
UnknownUsername,
InvalidPassword,
UsernameTaken,
}
impl From<ServerError> for ServerMsg {
fn from(value: ServerError) -> Self {
Self::Error(value)
}
}
pub type ServerResp<T> = Result<T, String>;
#[derive(Debug, Clone, bincode::Encode, bincode::Decode)]
pub struct NetMsg {
pub struct NetClientMsg {
pub content: String,
}
#[derive(Debug, Clone, bincode::Encode, bincode::Decode)]
pub struct NetServerMsg {
pub content: String,
pub user: String,
}
impl From<NetServerMsg> for ServerMsg {
fn from(value: NetServerMsg) -> Self {
Self::SendMsg(value)
}
}
pub fn install_crypto_provider() {
quinn::rustls::crypto::ring::default_provider()
.install_default()