Add to_string and from_string methods to network types
This commit is contained in:
parent
a1cfba63ff
commit
207e2d1d73
@ -105,6 +105,10 @@ impl CipherMessage {
|
|||||||
error: None,
|
error: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_string(&self) -> String {
|
||||||
|
serde_json::to_string(self).unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Tsify)]
|
#[derive(Debug, Serialize, Deserialize, Tsify)]
|
||||||
@ -121,6 +125,15 @@ impl AnkNetworkMsg {
|
|||||||
content: raw.into(),
|
content: raw.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_string(json: &str) -> Result<Self> {
|
||||||
|
let res: Self = serde_json::from_str(json)?;
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_string(&self) -> String {
|
||||||
|
serde_json::to_string(self).unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Tsify, Clone)]
|
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Tsify, Clone)]
|
||||||
@ -178,6 +191,15 @@ impl CachedMessage {
|
|||||||
new
|
new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_string(json: &str) -> Result<Self> {
|
||||||
|
let res = serde_json::from_str(json)?;
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_string(&self) -> String {
|
||||||
|
serde_json::to_string(self).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn try_decrypt_cipher(&self, cipher: Vec<u8>) -> Result<Vec<u8>> {
|
pub fn try_decrypt_cipher(&self, cipher: Vec<u8>) -> Result<Vec<u8>> {
|
||||||
if self.ciphertext.is_some() || self.shared_secret.is_none() {
|
if self.ciphertext.is_some() || self.shared_secret.is_none() {
|
||||||
return Err(Error::msg(
|
return Err(Error::msg(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user