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
impl TryConstruct
Sourcepub const ABSENT: Self = Self::Discard
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.
Sourcepub const BARE: Self = Self::UseDefault
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.
Sourcepub fn parse(value: &str) -> Option<Self>
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.
Sourcepub const fn trim_is_defined_for(kind: &TypeKind) -> bool
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.”