Skip to main content

Encode

Trait Encode 

Source
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§

Source

const OCTET_BOUNDARY: usize

Octet boundary of the datatype: its encoding starts at a multiple of this offset.

Required Methods§

Source

fn encode(&self, writer: &mut ByteWriter<'_>)

Appends the encoding of self, preceded by the padding its octet boundary requires.

Provided Methods§

Source

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.

Source§

const OCTET_BOUNDARY: usize = 4

Source§

fn encode(&self, writer: &mut ByteWriter<'_>)

Source§

impl Encode for str

Encoded as HLAunicodeString.

Source§

const OCTET_BOUNDARY: usize = 4

Source§

fn encode(&self, writer: &mut ByteWriter<'_>)

Source§

impl<T: Encode + ?Sized> Encode for &T

Source§

const OCTET_BOUNDARY: usize = T::OCTET_BOUNDARY

Source§

fn encode(&self, writer: &mut ByteWriter<'_>)

Source§

impl<T: Encode + ?Sized> Encode for Box<T>

Source§

const OCTET_BOUNDARY: usize = T::OCTET_BOUNDARY

Source§

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.

Source§

const OCTET_BOUNDARY: usize = T::OCTET_BOUNDARY

Source§

fn encode(&self, writer: &mut ByteWriter<'_>)

Source§

impl<T: Encode> Encode for Vec<T>

HLAvariableArray of T.

Source§

const OCTET_BOUNDARY: usize = <[T] as Encode>::OCTET_BOUNDARY

Source§

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.

Source§

const OCTET_BOUNDARY: usize

Source§

fn encode(&self, writer: &mut ByteWriter<'_>)

Implementors§

Source§

impl Encode for HLAASCIIchar

Source§

impl Encode for HLAASCIIstring

Source§

impl Encode for HLAattributeHandle

Source§

impl Encode for HLAboolean

Source§

impl Encode for HLAbyte

Source§

impl Encode for HLAdimensionHandle

Source§

impl Encode for HLAfederateHandle

Source§

impl Encode for HLAfloat32BE

Source§

impl Encode for HLAfloat32LE

Source§

impl Encode for HLAfloat64BE

Source§

impl Encode for HLAfloat64LE

Source§

impl Encode for HLAinteger16BE

Source§

impl Encode for HLAinteger16LE

Source§

impl Encode for HLAinteger32BE

Source§

impl Encode for HLAinteger32LE

Source§

impl Encode for HLAinteger64BE

Source§

impl Encode for HLAinteger64LE

Source§

impl Encode for HLAinteractionClassHandle

Source§

impl Encode for HLAlogicalTime

Source§

impl Encode for HLAlogicalTimeInterval

Source§

impl Encode for HLAmessageRetractionHandle

Source§

impl Encode for HLAobjectClassHandle

Source§

impl Encode for HLAobjectInstanceHandle

Source§

impl Encode for HLAoctet

Source§

impl Encode for HLAoctetPairBE

Source§

impl Encode for HLAoctetPairLE

Source§

impl Encode for HLAopaqueData

Source§

impl Encode for HLAparameterHandle

Source§

impl Encode for HLAregionHandle

Source§

impl Encode for HLAtransportationTypeHandle

Source§

impl Encode for HLAunicodeChar

Source§

impl Encode for HLAunicodeString

Source§

impl Encode for HLAunsignedInteger8

Source§

impl Encode for HLAunsignedInteger16BE

Source§

impl Encode for HLAunsignedInteger16LE

Source§

impl Encode for HLAunsignedInteger32BE

Source§

impl Encode for HLAunsignedInteger32LE

Source§

impl Encode for HLAunsignedInteger64BE

Source§

impl Encode for HLAunsignedInteger64LE