Skip to main content

TryConstruct

Enum TryConstruct 

Source
pub enum TryConstruct {
    Discard,
    UseDefault,
    Trim,
}
Expand description

@try_construct behaviour. DDS-XTypes 1.3 §7.2.2.7, §7.3.1.2.1.12.

What a receiver does when an object of the sender’s type cannot construct any object of the receiver’s type — an over-long string, a sequence with more elements than the bound holds, an enumerator the receiver does not declare.

Variants§

§

Discard

The failure propagates: the containing collection or aggregate cannot be constructed either, and at the top level the sample is discarded.

§

UseDefault

The element or member takes the default value of its type (Table 9) and the container is constructed.

§

Trim

A string, wstring, sequence or map is truncated to what the receiver’s bound holds, preserving order. On any other type the clause leaves the behaviour unspecified.

Implementations§

Source§

impl TryConstruct

Source

pub const ALL: [Self; 3]

Every behaviour XTypes defines.

Source

pub const ABSENT: Self = Self::Discard

What applies where nothing was written.

§7.2.2.7: “The default behavior unless otherwise specified using the TryConstruct annotation is DISCARD.” Note that this is the default for an absent annotation. The annotation’s own parameter defaults to USE_DEFAULT (§7.3.1.2.1.12), so a bare @try_construct is not the same as no annotation at all.

Source

pub const BARE: Self = Self::UseDefault

What a bare @try_construct, written with no argument, means.

§7.3.1.2.1.12 declares TryConstructFailAction value default USE_DEFAULT and spells it out: “If the annotation is specified without a value, or if the value is set to USE_DEFAULT, then the behavior is set to DEFAULT”. Measured: OpenDDS constructs the empty string for @try_construct string<5> against a writer’s twelve-character value — crates/ast-layout/tests/fixtures/try_construct_behaviour.md.

Source

pub const fn as_str(self) -> &'static str

The spelling the annotation argument uses.

Source

pub fn parse(value: &str) -> Option<Self>

Parse an annotation argument, in the spelling Self::as_str produces.

An unknown value returns None rather than the default: the setting decides whether a sample survives, and a typo in it must be loud.

Source

pub const fn trim_is_defined_for(kind: &TypeKind) -> bool

Whether TRIM is defined for this type kind.

Table 11: “This option only applies to elements or members of type string, wide string, sequence, or map. The behavior when applied to other element/member types is unspecified and may be treated as an error.”

Trait Implementations§

Source§

impl Clone for TryConstruct

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 Copy for TryConstruct

Source§

impl Debug for TryConstruct

Source§

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

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

impl Eq for TryConstruct

Source§

impl Hash for TryConstruct

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TryConstruct

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

impl StructuralPartialEq for TryConstruct

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.