Skip to main content

TypeKind

Enum TypeKind 

Source
pub enum TypeKind {
Show 19 variants Primitive(PrimitiveKind), Fixed { digits: u8, scale: u8, }, String { width: CharWidth, bound: Bound, }, Sequence { element: Ref<TypeNode>, bound: Bound, }, Array { element: Ref<TypeNode>, dims: Vec<Id<ConstExprNode>>, }, Map { key: Ref<TypeNode>, value: Ref<TypeNode>, bound: Bound, }, Structure { base: Option<Ref<TypeNode>>, members: Vec<Id<MemberNode>>, }, Union { discriminator: Ref<TypeNode>, cases: Vec<Id<CaseNode>>, default_case: Option<Id<CaseNode>>, }, Enumeration { enumerators: Vec<Id<EnumeratorNode>>, }, Bitmask { bits: Vec<Id<BitValueNode>>, }, Bitset { base: Option<Ref<TypeNode>>, fields: Vec<Id<BitfieldNode>>, }, Alias { aliased: Ref<TypeNode>, }, Valuetype { kind: ValuetypeKind, bases: Vec<Ref<TypeNode>>, state: Vec<Id<MemberNode>>, initializers: Vec<Id<OperationNode>>, supported: Vec<Ref<InterfaceNode>>, }, ValueBox { boxed: Ref<TypeNode>, }, Native, ValueBase, Any, ObjectRef { interface: Option<Ref<InterfaceNode>>, }, AnnotationType { definition: Id<AnnotationDefNode>, },
}
Expand description

What kind of type this is.

Spec §3.2 — the table there is normative and this enum mirrors it row for row.

Exhaustive on purpose, for the same reason as crate::NodeKind: a consumer mapping types onto another representation has to account for each one, and a catch-all would let a new kind pass as nothing.

Variants§

§

Primitive(PrimitiveKind)

Built-in scalar.

§

Fixed

fixed<digits, scale>.

Fields

§digits: u8

Total digits.

§scale: u8

Digits after the point.

§

String

string or wstring.

Fields

§width: CharWidth

Character width.

§bound: Bound

Optional bound.

§

Sequence

sequence<T> or sequence<T, N>.

Fields

§element: Ref<TypeNode>

Element type.

§bound: Bound

Optional bound.

§

Array

T name[d1][d2].

Fields

§element: Ref<TypeNode>

Element type.

§dims: Vec<Id<ConstExprNode>>

Dimensions, outermost first.

§

Map

map<K, V> or map<K, V, N>.

Fields

§key: Ref<TypeNode>

Key type.

§value: Ref<TypeNode>

Value type.

§bound: Bound

Optional bound.

§

Structure

struct.

Fields

§base: Option<Ref<TypeNode>>

Base type for single inheritance.

§members: Vec<Id<MemberNode>>

Members in declaration order.

§

Union

union.

Fields

§discriminator: Ref<TypeNode>

Discriminator type.

§cases: Vec<Id<CaseNode>>

Cases in declaration order.

§default_case: Option<Id<CaseNode>>

The default: case, if declared.

§

Enumeration

enum.

Fields

§enumerators: Vec<Id<EnumeratorNode>>

Enumerators in declaration order.

§

Bitmask

bitmask.

Fields

§bits: Vec<Id<BitValueNode>>

Bit values in declaration order.

§

Bitset

bitset.

Fields

§base: Option<Ref<TypeNode>>

Inherited bitset.

§fields: Vec<Id<BitfieldNode>>

Bitfields in declaration order.

§

Alias

typedef.

Fields

§aliased: Ref<TypeNode>

The aliased type.

§

Valuetype

valuetype.

Fields

§kind: ValuetypeKind

Modifier.

§bases: Vec<Ref<TypeNode>>

Base valuetypes.

§state: Vec<Id<MemberNode>>

State members in declaration order.

§initializers: Vec<Id<OperationNode>>

Initialisers.

§supported: Vec<Ref<InterfaceNode>>

Supported interfaces.

§

ValueBox

Boxed value.

Fields

§boxed: Ref<TypeNode>

The boxed type.

§

Native

native — opaque, name only.

§

ValueBase

ValueBase. OMG IDL 4.2 §7.4.7, rules (131) and (132).

The abstract base every valuetype has, written as a type: a value of any valuetype, whichever one arrives. It carries no reference for the same reason Object carries none — rule (131) is <value_base_type> ::= "ValueBase" and names nothing — and no state, because the base declares none.

CORBA CDR encodes one as a chunked value with its repository id ahead of it. DDS-XTypes has neither valuetypes nor this, so the layout planner refuses it by name.

§

Any

any. OMG IDL 4.2 §7.4.2, rules (69) and (70).

A value of any type, carrying its own type description. Building Block Any is one of the fifteen and this project takes all fifteen, so it is in the model — but it has no wire form under DDS-XTypes, which has no any at all. CORBA CDR writes a TypeCode and then the value; that is the only encoding in which it means anything, and the layout planner refuses it by name for every other one.

It carries no reference: what an any holds is decided at run time and is not part of the declaration.

§

ObjectRef

An object reference.

Either the generic one — Object, OMG IDL 4.2 §7.4.6 rules (117) and (118) — or an interface used as a data type.

Fields

§interface: Option<Ref<InterfaceNode>>

The referenced interface, absent for the generic Object.

Rule (117) is <object_type> ::= "Object" and names no interface at all, so there is nothing to point at. None says that, where a reference to an invented CORBA::Object declaration would say the file had one.

§

AnnotationType

A type introduced by an @annotation declaration.

Fields

§definition: Id<AnnotationDefNode>

The declaration.

Implementations§

Source§

impl TypeKind

Source

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

Short name, for diagnostics.

Source

pub const fn is_member_aggregate(&self) -> bool

Whether this kind aggregates members that carry member ids — struct and valuetype state. Union cases carry ids through their member, which is why unions are not listed here.

Source

pub fn members(&self) -> &[Id<MemberNode>]

The members of an aggregate, empty for every other kind.

Source

pub fn type_refs(&self) -> Vec<&Ref<TypeNode>>

Every type this kind references directly, resolved or not.

Drives cycle-safe traversal and layout dependency collection.

Source

pub fn type_refs_mut(&mut self) -> Vec<&mut Ref<TypeNode>>

The same references, mutably and in the same order.

The order is the slot numbering the undo log uses to name one reference of a kind that holds several, so the two functions have to stay in step; both are written as one match over every kind.

Trait Implementations§

Source§

impl Clone for TypeKind

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 Debug for TypeKind

Source§

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

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

impl Eq for TypeKind

Source§

impl PartialEq for TypeKind

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 TypeKind

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.