Skip to main content

TypeIdentifier

Enum TypeIdentifier 

Source
#[non_exhaustive]
pub enum TypeIdentifier {
Show 16 variants None, Primitive(PrimitiveKind), String8Small { bound: u8, }, String8Large { bound: u32, }, String16Small { bound: u8, }, String16Large { bound: u32, }, PlainSequenceSmall { header: PlainCollectionHeader, bound: u8, element: Box<TypeIdentifier>, }, PlainSequenceLarge { header: PlainCollectionHeader, bound: u32, element: Box<TypeIdentifier>, }, PlainArraySmall { header: PlainCollectionHeader, array_bounds: Vec<u8>, element: Box<TypeIdentifier>, }, PlainArrayLarge { header: PlainCollectionHeader, array_bounds: Vec<u32>, element: Box<TypeIdentifier>, }, PlainMapSmall { header: PlainCollectionHeader, bound: u8, element: Box<TypeIdentifier>, key_flags: CollectionElementFlag, key: Box<TypeIdentifier>, }, PlainMapLarge { header: PlainCollectionHeader, bound: u32, element: Box<TypeIdentifier>, key_flags: CollectionElementFlag, key: Box<TypeIdentifier>, }, StronglyConnectedComponent(StronglyConnectedComponentId), EquivalenceHashMinimal(EquivalenceHash), EquivalenceHashComplete(EquivalenceHash), Unknown(u8),
}
Expand description

TypeIdentifier — XTypes §7.3.4.2.

Identifies primitive and plain types directly, composite types (struct, union, etc.) indirectly (via a 14-byte hash). Plain collections can recursively contain a TypeIdentifier, hence Box for the nested variants.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

None

TK_NONE — spec sentinel for “no TypeIdentifier known”.

§

Primitive(PrimitiveKind)

Primitive without a body — the discriminator carries all info.

§

String8Small

string<Bound> with 8-bit characters, Bound <= 255 bytes.

Fields

§bound: u8

Max length (0 = unbounded).

§

String8Large

string<Bound> with Bound > 255.

Fields

§bound: u32

Max length.

§

String16Small

wstring<Bound> with Bound <= 255 chars.

Fields

§bound: u8

Max length.

§

String16Large

wstring<Bound>.

Fields

§bound: u32

Max length.

§

PlainSequenceSmall

sequence<T, N> with N <= 255.

Fields

§header: PlainCollectionHeader

Header (EquivKind of the element + flags).

§bound: u8

Maximum bound (0 = unbounded).

§element: Box<TypeIdentifier>

Element TypeIdentifier.

§

PlainSequenceLarge

sequence<T, N> with N > 255.

Fields

§header: PlainCollectionHeader

Header.

§bound: u32

Max bound.

§element: Box<TypeIdentifier>

Element TypeIdentifier.

§

PlainArraySmall

T[D1, D2, ...] with all dimensions <= 255.

Fields

§header: PlainCollectionHeader

Header.

§array_bounds: Vec<u8>

Array dimensions (max 2^20 total per §7.3.4.7).

§element: Box<TypeIdentifier>

Element TypeIdentifier.

§

PlainArrayLarge

T[D1, D2, ...] with at least one dimension > 255.

Fields

§header: PlainCollectionHeader

Header.

§array_bounds: Vec<u32>

Array dimensions.

§element: Box<TypeIdentifier>

Element TypeIdentifier.

§

PlainMapSmall

map<K, V, N> with N <= 255.

Fields

§header: PlainCollectionHeader

Header.

§bound: u8

Max size.

§element: Box<TypeIdentifier>

Value TypeIdentifier.

§key_flags: CollectionElementFlag

Key flags.

§key: Box<TypeIdentifier>

Key TypeIdentifier.

§

PlainMapLarge

map<K, V, N> with N > 255.

Fields

§header: PlainCollectionHeader

Header.

§bound: u32

Max size.

§element: Box<TypeIdentifier>

Value TypeIdentifier.

§key_flags: CollectionElementFlag

Key flags.

§key: Box<TypeIdentifier>

Key TypeIdentifier.

§

StronglyConnectedComponent(StronglyConnectedComponentId)

Strongly connected component (recursive types) — §7.3.4.9.

§

EquivalenceHashMinimal(EquivalenceHash)

14-byte hash of the MinimalTypeObject.

§

EquivalenceHashComplete(EquivalenceHash)

14-byte hash of the CompleteTypeObject.

§

Unknown(u8)

Unknown/unsupported discriminator (forward-compat).

Implementations§

Source§

impl TypeIdentifier

Source

pub const MAX_DECODE_DEPTH: usize = 16

Maximum recursion depth when wire-decoding a nested TypeIdentifier (plain collections can reference recursively). Protects against stack overflow on pathological datagrams.

Source

pub fn encode_into(&self, w: &mut BufferWriter) -> Result<(), EncodeError>

Encoded as XCDR2 little-endian bytes (TypeIdentifier without an encapsulation header — that is provided by the caller, e.g. the TYPE_INFORMATION PID or the TypeLookup RPC).

§Errors

EncodeError on buffer overflow (very unlikely for normal types; the 2^32 limit for large kinds).

Source

pub fn decode_from(r: &mut BufferReader<'_>) -> Result<Self, DecodeError>

Decode from XCDR2 little-endian bytes. The reader must be positioned at the discriminator. Internal recursion is capped (see Self::MAX_DECODE_DEPTH).

§Errors

DecodeError on buffer underflow, an inconsistent length field or when the maximum recursion depth is exceeded.

Source

pub const fn discriminator(&self) -> u8

The discriminator byte for this TypeIdentifier.

Source

pub fn to_bytes_le(&self) -> Result<Vec<u8>, EncodeError>

Kurzform: encode in neuen BufferWriter, LE.

§Errors

EncodeError on overflow.

Source

pub fn from_bytes_le(bytes: &[u8]) -> Result<Self, DecodeError>

Short form: decode from LE bytes.

§Errors

DecodeError.

Trait Implementations§

Source§

impl Clone for TypeIdentifier

Source§

fn clone(&self) -> TypeIdentifier

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 TypeIdentifier

Source§

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

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

impl Default for TypeIdentifier

Source§

fn default() -> TypeIdentifier

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

impl Eq for TypeIdentifier

Source§

impl PartialEq for TypeIdentifier

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TypeIdentifier

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.