Skip to main content

HLAextendableVariantRecord

Struct HLAextendableVariantRecord 

Source
pub struct HLAextendableVariantRecord { /* private fields */ }
Expand description

HLAextendableVariantRecord (IEEE 1516.2 4.14.10.3): a variant record whose encoding states the length of the alternative, so that a receiver skips alternatives it does not know and other FOM modules can add alternatives (4.14.8, annex C).

Decoding a discriminant without association is therefore not an error: the discriminant becomes the active one, the octets of its alternative are kept in Self::unknown_alternative, and Self::value fails as the standard APIs prescribe. The same holds for data received for a discriminant registered without data; encoding passes those octets on.

The layout is described in the extendable module.

Implementations§

Source§

impl HLAextendableVariantRecord

Source

pub fn set_variant( &mut self, discriminant: impl DataElement, value: impl DataElement, ) -> Result<&mut Self, EncoderError>

Associates value with discriminant and makes that discriminant the active one. A previous association of the same discriminant is replaced.

The discriminant must have the datatype of the discriminant prototype.

Source

pub fn set_empty_variant( &mut self, discriminant: impl DataElement, ) -> Result<&mut Self, EncoderError>

Registers discriminant as an enumerator without alternative data and makes it the active one.

Source

pub fn set_discriminant( &mut self, discriminant: impl DataElement, ) -> Result<&mut Self, EncoderError>

Makes discriminant the active one. It needs no association yet, but encoding fails until it has one.

Source

pub fn discriminant(&self) -> &DynElement

The active discriminant.

Source

pub fn discriminant_as<T: DataElement>(&self) -> Option<&T>

The active discriminant as a T, if it is one.

Source

pub fn value_as<T: DataElement>(&self) -> Option<&T>

The active alternative as a T, if there is one and it is a T.

Source

pub fn has_variant(&self, discriminant: &DynElement) -> bool

True if discriminant has been registered with Self::set_variant or Self::set_empty_variant.

Source

pub fn variant_count(&self) -> usize

Number of registered discriminants.

Source§

impl HLAextendableVariantRecord

Source

pub fn new(discriminant_prototype: impl DataElement) -> Self

A record whose discriminants have the datatype of discriminant_prototype, which is also the initial active discriminant.

Source

pub fn value(&self) -> Result<&DynElement, EncoderError>

The alternative of the active discriminant.

Fails with EncoderError::NoVariantForDiscriminant when the active discriminant has no association or no alternative data.

Source

pub fn value_mut(&mut self) -> Result<&mut DynElement, EncoderError>

The alternative of the active discriminant, mutable.

Source

pub fn unknown_alternative(&self) -> Option<&[u8]>

The octets of the alternative that the last decoding skipped because its discriminant has no association, or one without data; None when the last decoding used the registered alternative. For a discriminant registered without data, encoding passes these octets on.

Trait Implementations§

Source§

impl Clone for HLAextendableVariantRecord

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DataElement for HLAextendableVariantRecord

Source§

fn octet_boundary(&self) -> usize

Octet boundary of this element.
Source§

fn encode_into(&self, writer: &mut ByteWriter<'_>) -> Result<(), EncoderError>

Appends the padding this element needs and its encoding.
Source§

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

Skips the padding this element needs and replaces its value by the decoded one. Read more
Source§

fn clone_element(&self) -> Box<DynElement>

A boxed copy of this element.
Source§

fn is_same_type_as(&self, other: &DynElement) -> bool

True if other has the same datatype: the same Rust type and, for dynamic containers, the same structure.
Source§

fn encoded_length(&self) -> Result<usize, EncoderError>

Length in octets of the encoding when it starts at an aligned offset.
Source§

fn to_bytes(&self) -> Result<Vec<u8>, EncoderError>

Encodes this element as an outermost value.
Source§

fn append_to(&self, buffer: &mut Vec<u8>) -> Result<(), EncoderError>

Appends the encoding to 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>

Decodes this element from the start of bytes; octets after the value are ignored.
Source§

fn decode_slice_strict(&mut self, bytes: &[u8]) -> Result<(), DecoderError>

Decodes this element from bytes, which must hold exactly one value.
Source§

impl Debug for HLAextendableVariantRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for HLAextendableVariantRecord

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.