accounts are now real
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user