Added methods to serialize/deserialize the session w bincode

This commit is contained in:
Mahesh Bansod 2021-11-02 20:57:54 +05:30
parent b37ffd766e
commit 824747041b
2 changed files with 11 additions and 3 deletions

View File

@ -10,7 +10,8 @@ socialvoid_rawclient = {path = "../rawclient"}
socialvoid_types = {path = "../types"}
tokio = {version = "1.11.0", features = ["full"]}
serde_json = "1.0.67"
serde = { version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive","rc"]}
bincode = "1.3.3"
rand = "0.8.4"
sha256 = "1.0.2"
byteorder = "1.4.3"

View File

@ -18,8 +18,7 @@ pub struct SessionEstablished {
pub challenge: String,
}
//TODO: maybe do serde thing
#[derive(Debug)]
#[derive(Debug, Serialize, Deserialize)]
pub struct SessionHolder {
pub established: Option<SessionEstablished>,
pub authenticated: bool,
@ -36,6 +35,14 @@ impl SessionHolder {
authenticated: false,
}
}
pub fn serialize(&self) -> Vec<u8> {
bincode::serialize(&self).unwrap()
}
pub fn deserialize(bytes: Vec<u8>) -> Self {
bincode::deserialize(&bytes).unwrap()
}
}
pub struct RegisterRequest {