#[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
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.
String8Large
string<Bound> with Bound > 255.
String16Small
wstring<Bound> with Bound <= 255 chars.
String16Large
wstring<Bound>.
PlainSequenceSmall
sequence<T, N> with N <= 255.
Fields
header: PlainCollectionHeaderHeader (EquivKind of the element + flags).
element: Box<TypeIdentifier>Element TypeIdentifier.
PlainSequenceLarge
sequence<T, N> with N > 255.
PlainArraySmall
T[D1, D2, ...] with all dimensions <= 255.
PlainArrayLarge
T[D1, D2, ...] with at least one dimension > 255.
PlainMapSmall
map<K, V, N> with N <= 255.
Fields
header: PlainCollectionHeaderHeader.
element: Box<TypeIdentifier>Value TypeIdentifier.
key_flags: CollectionElementFlagKey flags.
key: Box<TypeIdentifier>Key TypeIdentifier.
PlainMapLarge
map<K, V, N> with N > 255.
Fields
header: PlainCollectionHeaderHeader.
element: Box<TypeIdentifier>Value TypeIdentifier.
key_flags: CollectionElementFlagKey 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
impl TypeIdentifier
Sourcepub const MAX_DECODE_DEPTH: usize = 16
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.
Sourcepub fn encode_into(&self, w: &mut BufferWriter) -> Result<(), EncodeError>
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).
Sourcepub fn decode_from(r: &mut BufferReader<'_>) -> Result<Self, DecodeError>
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.
Sourcepub const fn discriminator(&self) -> u8
pub const fn discriminator(&self) -> u8
The discriminator byte for this TypeIdentifier.
Sourcepub fn to_bytes_le(&self) -> Result<Vec<u8>, EncodeError>
pub fn to_bytes_le(&self) -> Result<Vec<u8>, EncodeError>
Sourcepub fn from_bytes_le(bytes: &[u8]) -> Result<Self, DecodeError>
pub fn from_bytes_le(bytes: &[u8]) -> Result<Self, DecodeError>
Trait Implementations§
Source§impl Clone for TypeIdentifier
impl Clone for TypeIdentifier
Source§fn clone(&self) -> TypeIdentifier
fn clone(&self) -> TypeIdentifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypeIdentifier
impl Debug for TypeIdentifier
Source§impl Default for TypeIdentifier
impl Default for TypeIdentifier
Source§fn default() -> TypeIdentifier
fn default() -> TypeIdentifier
impl Eq for TypeIdentifier
Source§impl PartialEq for TypeIdentifier
impl PartialEq for TypeIdentifier
Source§fn eq(&self, other: &TypeIdentifier) -> bool
fn eq(&self, other: &TypeIdentifier) -> bool
self and other values to be equal, and is used by ==.