Skip to main content

KeyOnUnionDiscriminator

Enum KeyOnUnionDiscriminator 

Source
pub enum KeyOnUnionDiscriminator {
    Refused,
    Carried,
}
Expand description

Re-exported because ComposeOptions carries them in public fields, exactly as zerodds-idl-compose re-exports them: a caller that cannot name the type cannot construct the options. Whether @key on a union discriminator is carried into the model.

§The clause permits it

DDS-XTypes 1.3 Table 21 lists @key against “Structure Members, Union discriminator”, and §7.2.2.4.4.4.8’s own example is

union MyCommand switch (@key CommandKind) { /* … */ };

so the default is to carry it: a front end that refuses the declaration, or tells the author the annotation “has no meaning” there, states the opposite of the specification.

§What the implementations do

Measured on the four toolchains the Linux test host carries:

union U switch (@key uint32)
Cyclone idlcrefuses the file — “Using union type as part of the key is currently unsupported”
rtiddsgenrefuses it at the discriminator — “@key is not supported”
fastddsgengenerates no PubSubType for a union at all, so it has no keyed topic to compare against
opendds_idlnot recorded in that run

So under Self::Carried this project computes a KeyHash over a union discriminator that no measured peer computes. Self::Refused is the setting for a tool that has to stay within what those toolchains accept; it names the clause that permits the declaration in its diagnostic.

§Why the OMG suite needs it

union_uint32_one_key pairs unions.xml’s union_uint32 against unions_key_discriminator.xml’s union_uint32_key, whose discriminator carries key="true", and expects INCONSISTENT_TOPIC on both sides: §7.2.4.4.4.5 requires that “either the discriminators of both T1 and T2 are keys or neither are keys”. Under Self::Refused the subscriber never creates the topic and the case reports TOPIC_NOT_CREATED; under Self::Carried the declaration loads, the discriminator’s IS_KEY reaches its TypeObject, and the two types are found not assignable — which is the verdict the suite asks for.

A named type and not a bool for the reason HashedIdCounter is one: Options is Default, and a boolean defaulting to false would carry no statement about which reading that is.

Variants§

§

Refused

The annotation is reported and the declaration does not carry it. What the measured toolchains do.

§

Carried

The annotation is carried: the model records it, the discriminator’s UnionDiscriminatorFlag gets IS_KEY, the union is a keyed topic type and its KeyHash is computed over the discriminator alone. The default, as Table 21 and §7.2.2.4.4.4.8 have it.

Implementations§

Source§

impl KeyOnUnionDiscriminator

Source

pub const ALL: [KeyOnUnionDiscriminator; 2]

Both.

Source

pub const fn is_default(self) -> bool

Whether this is the default.

Source

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

Short name, for configuration and diagnostics.

Source

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

Parse a configuration value.

An unknown value returns None rather than falling back to the default: a typo here changes a type’s TypeIdentifier.

Trait Implementations§

Source§

impl Clone for KeyOnUnionDiscriminator

Source§

fn clone(&self) -> KeyOnUnionDiscriminator

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 KeyOnUnionDiscriminator

Source§

impl Debug for KeyOnUnionDiscriminator

Source§

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

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

impl Default for KeyOnUnionDiscriminator

Source§

fn default() -> KeyOnUnionDiscriminator

Returns the “default value” for a type. Read more
Source§

impl Eq for KeyOnUnionDiscriminator

Source§

impl PartialEq for KeyOnUnionDiscriminator

Source§

fn eq(&self, other: &KeyOnUnionDiscriminator) -> 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 KeyOnUnionDiscriminator

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.