ootle_byte_type
Lightweight conversion traits between rich types and their flat fixed byte-array representations. Useful for serialisation boundaries where allocating or expensive Edwards point decompression operations are undesirable.
Traits
| Trait | Direction | Method |
|---|---|---|
ToByteType |
T → Bytes |
to_byte_type(&self) -> Self::ByteType |
ConvertFromByteType<B> |
Bytes → T |
convert_from_byte_type(bytes: &B) -> Result<Self, _> |
FromByteType<T> |
Bytes → T (blanket) |
try_from_byte_type(&self) -> Result<T, _> |
FromByteType is automatically implemented for any B where T: ConvertFromByteType<B>,
so you only need to implement ConvertFromByteType.
Example
use ;
use ;
use RistrettoPublicKeyBytes;
// Rich type → bytes
let = random_keypair;
let bytes: RistrettoPublicKeyBytes = pk.to_byte_type;
// Bytes → rich type
let pk2: RistrettoPublicKey = bytes.try_from_byte_type.unwrap;
assert_eq!;
With the crypto feature (enabled by default) implementations are provided for
RistrettoPublicKey, PedersenCommitment, SchnorrSignature,
CommitmentSignature, and Option<T>.
License
BSD-3-Clause. Copyright 2026 The Tari Project.