pub trait Encode {
const OCTET_BOUNDARY: usize;
// Required method
fn encode(&self, writer: &mut ByteWriter<'_>);
// Provided method
fn encoded_len(&self) -> usize { ... }
}Expand description
A Rust type with a fixed HLA encoding.
Implementations align the writer to Encode::OCTET_BOUNDARY before writing, so containers only have
to encode their parts in order: the padding in front of each part is the padding the standard places
after the previous one, and nothing is ever written after the last part.
Required Associated Constants§
Sourceconst OCTET_BOUNDARY: usize
const OCTET_BOUNDARY: usize
Octet boundary of the datatype: its encoding starts at a multiple of this offset.
Required Methods§
Sourcefn encode(&self, writer: &mut ByteWriter<'_>)
fn encode(&self, writer: &mut ByteWriter<'_>)
Appends the encoding of self, preceded by the padding its octet boundary requires.
Provided Methods§
Sourcefn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Length in octets of the encoding when it starts at an aligned offset.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Encode for String
Encoded as HLAunicodeString.
impl Encode for String
Encoded as HLAunicodeString.
const OCTET_BOUNDARY: usize = 4
fn encode(&self, writer: &mut ByteWriter<'_>)
Source§impl Encode for str
Encoded as HLAunicodeString.
impl Encode for str
Encoded as HLAunicodeString.
const OCTET_BOUNDARY: usize = 4
fn encode(&self, writer: &mut ByteWriter<'_>)
Source§impl<T: Encode + ?Sized> Encode for &T
impl<T: Encode + ?Sized> Encode for &T
const OCTET_BOUNDARY: usize = T::OCTET_BOUNDARY
fn encode(&self, writer: &mut ByteWriter<'_>)
Source§impl<T: Encode + ?Sized> Encode for Box<T>
impl<T: Encode + ?Sized> Encode for Box<T>
const OCTET_BOUNDARY: usize = T::OCTET_BOUNDARY
fn encode(&self, writer: &mut ByteWriter<'_>)
Source§impl<T: Encode, const N: usize> Encode for [T; N]
HLAfixedArray of N elements of T: the elements without a count.
impl<T: Encode, const N: usize> Encode for [T; N]
HLAfixedArray of N elements of T: the elements without a count.
const OCTET_BOUNDARY: usize = T::OCTET_BOUNDARY
fn encode(&self, writer: &mut ByteWriter<'_>)
Source§impl<T: Encode> Encode for Vec<T>
HLAvariableArray of T.
impl<T: Encode> Encode for Vec<T>
HLAvariableArray of T.
const OCTET_BOUNDARY: usize = <[T] as Encode>::OCTET_BOUNDARY
fn encode(&self, writer: &mut ByteWriter<'_>)
Source§impl<T: Encode> Encode for [T]
HLAvariableArray: element count as HLAinteger32BE, then the elements, each at its own boundary.
An empty array is the count alone.
impl<T: Encode> Encode for [T]
HLAvariableArray: element count as HLAinteger32BE, then the elements, each at its own boundary.
An empty array is the count alone.