pub struct HLAvariableArray { /* private fields */ }Expand description
HLAvariableArray (IEEE 1516.2 4.14.10.5): the element count as HLAinteger32BE, then the elements
of one datatype, each at its own octet boundary. An empty array is the count alone. The octet boundary
is the larger of 4 and the boundary of the element datatype.
Implementations§
Source§impl HLAvariableArray
impl HLAvariableArray
Sourcepub fn prototype(&self) -> &DynElement
pub fn prototype(&self) -> &DynElement
The element every member of the array must match.
Sourcepub fn get(&self, index: usize) -> Option<&DynElement>
pub fn get(&self, index: usize) -> Option<&DynElement>
The element at index.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut DynElement>
pub fn get_mut(&mut self, index: usize) -> Option<&mut DynElement>
The element at index, mutable. Its value may change, its datatype stays.
Sourcepub fn get_as<T: DataElement>(&self, index: usize) -> Option<&T>
pub fn get_as<T: DataElement>(&self, index: usize) -> Option<&T>
The element at index as a T, if it is one.
Sourcepub fn set(
&mut self,
index: usize,
element: impl DataElement,
) -> Result<(), EncoderError>
pub fn set( &mut self, index: usize, element: impl DataElement, ) -> Result<(), EncoderError>
Replaces the element at index by an element matching the prototype.
Sourcepub fn iter(&self) -> impl Iterator<Item = &DynElement>
pub fn iter(&self) -> impl Iterator<Item = &DynElement>
The elements in order.
Source§impl HLAvariableArray
impl HLAvariableArray
Sourcepub fn new(prototype: impl DataElement) -> Self
pub fn new(prototype: impl DataElement) -> Self
An empty array whose elements will match prototype.
Sourcepub fn from_elements<E: DataElement>(
prototype: impl DataElement,
elements: impl IntoIterator<Item = E>,
) -> Result<Self, EncoderError>
pub fn from_elements<E: DataElement>( prototype: impl DataElement, elements: impl IntoIterator<Item = E>, ) -> Result<Self, EncoderError>
An array holding elements, each of which must match prototype.
Sourcepub fn of<T: DataElement + Default>(
elements: impl IntoIterator<Item = T>,
) -> Self
pub fn of<T: DataElement + Default>( elements: impl IntoIterator<Item = T>, ) -> Self
An array of statically typed elements; the prototype is T::default().
Sourcepub fn push(
&mut self,
element: impl DataElement,
) -> Result<&mut Self, EncoderError>
pub fn push( &mut self, element: impl DataElement, ) -> Result<&mut Self, EncoderError>
Appends an element, which must match the prototype.
Trait Implementations§
Source§impl Clone for HLAvariableArray
impl Clone for HLAvariableArray
Source§impl DataElement for HLAvariableArray
impl DataElement for HLAvariableArray
Source§fn octet_boundary(&self) -> usize
fn octet_boundary(&self) -> usize
Source§fn encode_into(&self, writer: &mut ByteWriter<'_>) -> Result<(), EncoderError>
fn encode_into(&self, writer: &mut ByteWriter<'_>) -> Result<(), EncoderError>
Source§fn decode_from(
&mut self,
reader: &mut ByteReader<'_>,
) -> Result<(), DecoderError>
fn decode_from( &mut self, reader: &mut ByteReader<'_>, ) -> Result<(), DecoderError>
Source§fn clone_element(&self) -> Box<DynElement>
fn clone_element(&self) -> Box<DynElement>
Source§fn is_same_type_as(&self, other: &DynElement) -> bool
fn is_same_type_as(&self, other: &DynElement) -> bool
other has the same datatype: the same Rust type and, for dynamic containers, the same
structure.Source§fn encoded_length(&self) -> Result<usize, EncoderError>
fn encoded_length(&self) -> Result<usize, EncoderError>
Source§fn to_bytes(&self) -> Result<Vec<u8>, EncoderError>
fn to_bytes(&self) -> Result<Vec<u8>, EncoderError>
Source§fn append_to(&self, buffer: &mut Vec<u8>) -> Result<(), EncoderError>
fn append_to(&self, buffer: &mut Vec<u8>) -> Result<(), EncoderError>
buffer as a new outermost value: padding is computed from the first
appended octet. On error buffer is left unchanged.Source§fn decode_slice(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
fn decode_slice(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
bytes; octets after the value are ignored.Source§fn decode_slice_strict(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
fn decode_slice_strict(&mut self, bytes: &[u8]) -> Result<(), DecoderError>
bytes, which must hold exactly one value.