mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
fix serialize for keypair
This commit is contained in:
parent
17e4d17984
commit
d044f646bf
@ -1,5 +1,4 @@
|
||||
mod blake3digest512;
|
||||
mod byte_array_types;
|
||||
mod dh_cache;
|
||||
mod envelope;
|
||||
mod receipt;
|
||||
@ -13,7 +12,7 @@ pub mod tests;
|
||||
pub mod vld0;
|
||||
|
||||
pub use blake3digest512::*;
|
||||
pub use byte_array_types::*;
|
||||
|
||||
pub use crypto_system::*;
|
||||
pub use dh_cache::*;
|
||||
pub use envelope::*;
|
||||
|
@ -3,8 +3,7 @@ use super::*;
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
Default,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
PartialEq,
|
||||
@ -87,3 +86,26 @@ impl TryFrom<&str> for KeyPair {
|
||||
Self::try_decode(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::Serialize for KeyPair {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
let s = self.encode();
|
||||
serde::Serialize::serialize(&s, serializer)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'de> serde::Deserialize<'de> for KeyPair {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let s = <String as serde::Deserialize>::deserialize(deserializer)?;
|
||||
if s == "" {
|
||||
return Ok(KeyPair::default());
|
||||
}
|
||||
KeyPair::try_decode(s.as_str()).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,12 @@ pub fn common_crypto_kinds(a: &[CryptoKind], b: &[CryptoKind]) -> Vec<CryptoKind
|
||||
out
|
||||
}
|
||||
|
||||
mod byte_array_types;
|
||||
mod crypto_typed;
|
||||
mod crypto_typed_group;
|
||||
mod keypair;
|
||||
|
||||
pub use byte_array_types::*;
|
||||
pub use crypto_typed::*;
|
||||
pub use crypto_typed_group::*;
|
||||
pub use keypair::*;
|
||||
|
@ -150,6 +150,8 @@ class _JsonVeilidAPI(VeilidAPI):
|
||||
# Parse line as ndjson
|
||||
j = json.loads(linebytes.strip())
|
||||
|
||||
print(f"linebytes: {linebytes}")
|
||||
|
||||
if self.validate_schema:
|
||||
_schema_validate(_VALIDATOR_RECV_MESSAGE, j)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user