pub trait Packer {
// Required methods
fn size(&self) -> usize;
fn pack(&self, enc: &mut Encoder) -> usize;
fn unpack(&mut self, data: &[u8]) -> usize;
}
Expand description
The Packer
trait provides methods for packing and unpacking values to and from byte arrays.
§Examples
use crate::rust_chain::serializer::{Encoder, Decoder, Packer};
let mut encoder = Encoder::new(4);
let value = 123u32;
value.pack(&mut encoder);
let mut decoder = Decoder::new(&encoder.get_bytes());
let mut unpacked_value = 0u32;
decoder.unpack(&mut unpacked_value);
assert_eq!(value, unpacked_value);
Required Methods§
Implementations on Foreign Types§
Implementors§
impl Packer for BlockSigningAuthority
impl Packer for PublicKey
impl Packer for UserPresence
impl Packer for Action
Implements the Packer trait for Action to enable serialization and deserialization.
impl Packer for GetCodeHashResult
impl Packer for PermissionLevel
Implements the Packer trait for PermissionLevel to enable serialization and deserialization.
impl Packer for Asset
impl Packer for ExtendedAsset
impl Packer for Symbol
impl Packer for SymbolCode
impl Packer for Name
impl Packer for String
Implement Packer
for String
type.
impl Packer for BlockSigningAuthorityV0
impl Packer for BlockTimeStampType
impl Packer for Checksum160
impl Packer for Checksum256
impl Packer for Checksum512
impl Packer for ECCPublicKey
impl Packer for Float128
impl Packer for KeyWeight
impl Packer for ProducerAuthority
impl Packer for ProducerKey
impl Packer for Signature
impl Packer for TimePoint
impl Packer for TimePointSec
impl Packer for Uint256
impl Packer for WebAuthNPublicKey
impl Packer for Transaction
impl Packer for TransactionExtension
impl Packer for VarUint32
impl<T> Packer for BinaryExtension<T>
impl<T> Packer for Vec<T>
Implement Packer
for Vec<T>
type.