Skip to main content

Representation

Trait Representation 

Source
pub trait Representation<V> {
    const BOUNDARY: usize;

    // Required methods
    fn encode_value(value: &V, writer: &mut ByteWriter<'_>);
    fn decode_value(reader: &mut ByteReader<'_>) -> Result<V, DecoderError>;

    // Provided method
    fn encoded_len_of(value: &V) -> usize { ... }
}
Expand description

An encoding marker: Self names the HLA datatype used to carry Rust values of type V.

Every Decode type represents itself. In addition the basic wrappers represent their native type (HLAinteger32BE represents i32, HLAunicodeString represents String…), which lets the record macros keep plain Rust field types: count: i32 as HLAinteger32BE.

Required Associated Constants§

Source

const BOUNDARY: usize

Octet boundary of the datatype.

Required Methods§

Source

fn encode_value(value: &V, writer: &mut ByteWriter<'_>)

Encodes value as this datatype.

Source

fn decode_value(reader: &mut ByteReader<'_>) -> Result<V, DecoderError>

Decodes a value of this datatype.

Provided Methods§

Source

fn encoded_len_of(value: &V) -> usize

Encoded length of value 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".

Implementors§

Source§

impl Representation<String> for HLAunicodeString

Source§

impl Representation<Vec<u8>> for HLAopaqueData

Source§

impl Representation<bool> for HLAboolean

Source§

impl Representation<f32> for HLAfloat32BE

Source§

impl Representation<f32> for HLAfloat32LE

Source§

impl Representation<f64> for HLAfloat64BE

Source§

impl Representation<f64> for HLAfloat64LE

Source§

impl Representation<i16> for HLAinteger16BE

Source§

impl Representation<i16> for HLAinteger16LE

Source§

impl Representation<i32> for HLAinteger32BE

Source§

impl Representation<i32> for HLAinteger32LE

Source§

impl Representation<i64> for HLAinteger64BE

Source§

impl Representation<i64> for HLAinteger64LE

Source§

impl Representation<u8> for HLAASCIIchar

Source§

impl Representation<u8> for HLAbyte

Source§

impl Representation<u8> for HLAoctet

Source§

impl Representation<u8> for HLAunsignedInteger8

Source§

impl Representation<u16> for HLAoctetPairBE

Source§

impl Representation<u16> for HLAoctetPairLE

Source§

impl Representation<u16> for HLAunicodeChar

Source§

impl Representation<u16> for HLAunsignedInteger16BE

Source§

impl Representation<u16> for HLAunsignedInteger16LE

Source§

impl Representation<u32> for HLAunsignedInteger32BE

Source§

impl Representation<u32> for HLAunsignedInteger32LE

Source§

impl Representation<u64> for HLAunsignedInteger64BE

Source§

impl Representation<u64> for HLAunsignedInteger64LE

Source§

impl<T: Decode> Representation<T> for T

Source§

const BOUNDARY: usize = <T as Encode>::OCTET_BOUNDARY

Source§

impl<V, R: Representation<V>, const N: usize> Representation<[V; N]> for FixedArrayOf<R>

Source§

impl<V, R: Representation<V>> Representation<Vec<V>> for VariableArrayOf<R>