pub trait CompactEnvelope: Sized {
// Required methods
fn to_compact<B>(&self, buf: &mut B) -> usize
where B: BufMut + AsMut<[u8]>;
fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]);
}
Available on crate feature
test-utils
only.Expand description
Compact serialization for transaction envelopes with compression and bitfield packing.
Required Methods§
Sourcefn to_compact<B>(&self, buf: &mut B) -> usize
fn to_compact<B>(&self, buf: &mut B) -> usize
Takes a buffer which can be written to. Ideally, it returns the length written to.
Sourcefn from_compact(buf: &[u8], len: usize) -> (Self, &[u8])
fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8])
Takes a buffer which can be read from. Returns the object and buf
with its internal cursor
advanced (eg..advance(len)
).
len
can either be the buf
remaining length, or the length of the compacted type.
It will panic, if len
is smaller than buf.len()
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.