mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-12-16 08:14:26 -05:00
adding an impl from and into [u8; size] for byte array types
This commit is contained in:
parent
9f795ef520
commit
6b2c9ed48a
1 changed files with 25 additions and 0 deletions
|
|
@ -261,6 +261,18 @@ macro_rules! byte_array_type {
|
||||||
&mut self.bytes
|
&mut self.bytes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<[u8; $size]> for $name {
|
||||||
|
fn from(value: [u8; $size]) -> Self {
|
||||||
|
Self::new(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<$name> for [u8; $size] {
|
||||||
|
fn from(value: $name) -> Self {
|
||||||
|
value.bytes
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -283,3 +295,16 @@ pub type CryptoKeyDistance = CryptoKey;
|
||||||
|
|
||||||
byte_array_type!(Signature, SIGNATURE_LENGTH, SIGNATURE_LENGTH_ENCODED);
|
byte_array_type!(Signature, SIGNATURE_LENGTH, SIGNATURE_LENGTH_ENCODED);
|
||||||
byte_array_type!(Nonce, NONCE_LENGTH, NONCE_LENGTH_ENCODED);
|
byte_array_type!(Nonce, NONCE_LENGTH, NONCE_LENGTH_ENCODED);
|
||||||
|
|
||||||
|
|
||||||
|
// impl From<[u8; SIGNATURE_LENGTH]> for Signature {
|
||||||
|
// fn from(value: [u8; SIGNATURE_LENGTH]) -> Self {
|
||||||
|
// Self::new(value)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// impl From<Signature> for [u8; SIGNATURE_LENGTH] {
|
||||||
|
// fn from(value: Signature) -> Self {
|
||||||
|
// value.bytes
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue