pub trait DdsType: Sized {
const TYPE_NAME: &'static str;
const EXTENSIBILITY: Extensibility = Extensibility::Final;
const HAS_KEY: bool = false;
const IS_KEYED: bool = Self::HAS_KEY;
const KEY_HOLDER_MAX_SIZE: Option<usize> = None;
const IS_NESTED: bool = false;
const TYPE_IDENTIFIER: TypeIdentifier = zerodds_types::TypeIdentifier::None;
// Required methods
fn encode(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>;
fn decode(bytes: &[u8]) -> Result<Self, DecodeError>;
// Provided methods
fn encode_be(&self, out: &mut Vec<u8>) -> Result<(), EncodeError> { ... }
fn decode_be(bytes: &[u8]) -> Result<Self, DecodeError> { ... }
fn encode_xcdr1(&self, out: &mut Vec<u8>) -> Result<(), EncodeError> { ... }
fn decode_xcdr1(bytes: &[u8]) -> Result<Self, DecodeError> { ... }
fn decode_xcdr1_be(bytes: &[u8]) -> Result<Self, DecodeError> { ... }
fn encode_key_holder_be(&self, _holder: &mut PlainCdr2BeKeyHolder) { ... }
fn field_value(&self, _path: &str) -> Option<Value> { ... }
fn compute_key_hash(&self) -> Option<[u8; 16]> { ... }
fn key_hash(&self) -> Option<[u8; 16]> { ... }
}Expand description
A type that can be published/subscribed via DDS.
Required Associated Constants§
Provided Associated Constants§
Sourceconst EXTENSIBILITY: Extensibility = Extensibility::Final
const EXTENSIBILITY: Extensibility = Extensibility::Final
XTypes 1.3 §7.4.5 struct extensibility kind. Default Final
for backwards compat with pre-EXTENSIBILITY codegen outputs.
Spec: zerodds-xcdr2-rust §2.3.
Sourceconst HAS_KEY: bool = false
const HAS_KEY: bool = false
true if the topic type is keyed (at least one member with
a @key annotation). Default false — the caller (proc-macro)
overrides this for keyed types and also implements
Self::encode_key_holder_be.
Spec: XTypes 1.3 §7.6.8 (KeyHash requirement for keyed topics).
Note (zerodds-xcdr2-rust §11 errata): the spec references this
field as IS_KEYED. We keep HAS_KEY for source compat with
pre-1.0 code; the spec-aligned alias Self::IS_KEYED always
returns the same value.
Sourceconst IS_KEYED: bool = Self::HAS_KEY
const IS_KEYED: bool = Self::HAS_KEY
Spec-aligned alias for Self::HAS_KEY.
zerodds-xcdr2-rust §2 references this as IS_KEYED.
Sourceconst KEY_HOLDER_MAX_SIZE: Option<usize> = None
const KEY_HOLDER_MAX_SIZE: Option<usize> = None
Maximum size of the PLAIN_CDR2-BE KeyHolder stream in bytes
(XTypes 1.3 §7.6.8.4 step 5). None = not keyed or unbounded
(MD5 path). Some(n) with n <= 16 = zero-pad path.
Sourceconst IS_NESTED: bool = false
const IS_NESTED: bool = false
true if the type is annotated with @nested (XTypes 1.3
§7.4.6.3.5). Nested types are only intended as members of other
types and MUST NOT be registered as a DDS topic type.
DomainParticipant::create_topic rejects registration of
nested types with PreconditionNotMet.
Sourceconst TYPE_IDENTIFIER: TypeIdentifier = zerodds_types::TypeIdentifier::None
const TYPE_IDENTIFIER: TypeIdentifier = zerodds_types::TypeIdentifier::None
XTypes 1.3 §7.3.4.2 — TypeIdentifier of the type for
XTypes-aware discovery + compatibility matching. Default
TypeIdentifier::None signals “type-id not provided;
reader-writer matching falls back to plain type_name
comparison (DDS 1.4 §2.2.3 default path)”.
idl-rust codegen emits the appropriate TypeIdentifier here:
- Primitive
int32→TypeIdentifier::Primitive(PrimitiveKind::Int32), - String
string<N>→TypeIdentifier::String8Small{ bound }, - Composite struct →
TypeIdentifier::EquivalenceHash(once the TypeRegistry lookup is live).
Once both sides (writer + reader) provide a TypeIdentifier, the
subscriber match path calls
zerodds_types::type_matcher::TypeMatcher::match_types
(XTypes §7.6.3.7 + DDS 1.4 §2.2.3 TypeConsistencyEnforcement).
Required Methods§
Sourcefn encode(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>
fn encode(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>
Serializes self into the XCDR2 payload sent as the
serialized_payload of a DATA submessage. Default endianness:
little-endian (RTPS 2.5 §10.5
RepresentationIdentifier = CDR2_LE = 0x0010).
§Errors
CDR encoder error (buffer overflow, etc.).
Provided Methods§
Sourcefn encode_be(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>
fn encode_be(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>
Big-endian variant of Self::encode. The default
implementation delegates to Self::encode (no byte swap),
since a generic BE re-encode is not possible without type
reflection. Codegen overrides this for structures that should
genuinely go on the wire as BE. Spec: zerodds-xcdr2-rust §2.4.
§Errors
CDR encoder error.
Sourcefn decode_be(bytes: &[u8]) -> Result<Self, DecodeError>
fn decode_be(bytes: &[u8]) -> Result<Self, DecodeError>
Big-endian variant of Self::decode — for a payload whose
encapsulation header declared a big-endian representation identifier
(CDR_BE = 0x0000, PL_CDR_BE = 0x0002, CDR2_BE = 0x0006,
D_CDR2_BE = 0x0008, PL_CDR2_BE = 0x000a). The default implementation
delegates to Self::decode (little-endian) so pre-decode_be codegen
keeps working on the canonical wire; idl-rust codegen overrides this to
build a big-endian reader. Symmetric to Self::encode_be. Spec:
zerodds-xcdr2-rust §2.4; RTPS 2.5 §10.5.
§Errors
CDR decoder error.
Sourcefn encode_xcdr1(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>
fn encode_xcdr1(&self, out: &mut Vec<u8>) -> Result<(), EncodeError>
Serializes as classic CDR / XCDR1 little-endian (representation
CDR_LE = 0x0001, max-alignment 8, no DHEADER on @final/@appendable,
PL_CDR1 for @mutable). This is the encoding Cyclone DDS carries in an
iceoryx PSMX chunk for a serialized sample, so the iceoryx-cyclone
bridge uses it for cross-vendor same-host interop. The default delegates
to Self::encode (XCDR2) — correct only for types whose XCDR1 and
XCDR2 byte streams coincide (no 8-byte members, @final, no @mutable);
idl-rust codegen overrides it with a true XCDR1 writer.
§Errors
CDR encoder error.
Sourcefn decode_xcdr1(bytes: &[u8]) -> Result<Self, DecodeError>
fn decode_xcdr1(bytes: &[u8]) -> Result<Self, DecodeError>
Deserializes a classic-CDR / XCDR1 little-endian payload. Symmetric to
Self::encode_xcdr1; the default delegates to Self::decode and
idl-rust codegen overrides it with an XCDR1 reader.
§Errors
CDR decoder error.
Sourcefn decode_xcdr1_be(bytes: &[u8]) -> Result<Self, DecodeError>
fn decode_xcdr1_be(bytes: &[u8]) -> Result<Self, DecodeError>
Deserializes a classic-CDR / XCDR1 big-endian payload (encapsulation
CDR_BE = 0x0000 / PL_CDR_BE = 0x0002). The default delegates to
Self::decode_xcdr1 (little-endian) — correct for byte-order-agnostic
types and the common case (Cyclone/FastDDS/RTI emit XCDR1 little-endian);
idl-rust codegen overrides it with a true big-endian XCDR1 reader.
Symmetric to Self::decode_be for XCDR2.
§Errors
CDR decoder error.
Sourcefn encode_key_holder_be(&self, _holder: &mut PlainCdr2BeKeyHolder)
fn encode_key_holder_be(&self, _holder: &mut PlainCdr2BeKeyHolder)
Serializes the @key member values in PLAIN_CDR2-BE format
into the given PlainCdr2BeKeyHolder. Order: ascending by
member_id (XTypes 1.3 §7.6.8.3.1.b).
Default implementation: empty write. Keyed types MUST override this.
Called by the DcpsRuntime in the sample-encode path to write PID_KEY_HASH into the inline QoS.
Sourcefn field_value(&self, _path: &str) -> Option<Value>
fn field_value(&self, _path: &str) -> Option<Value>
Returns the value of a field path (dotted, e.g. "a.b") as a
zerodds_sql_filter::Value for SQL filter evaluation in
QueryCondition / ContentFilteredTopic. Default: None (no field
reachable — the filter then denies every sample that contains a
field access).
Spec: DDS 1.4 §B.2.1 (Filter Expressions) together with §2.2.2.5.9 (QueryCondition) and §2.2.2.3.5 (ContentFilteredTopic). Generated IDL stubs override this per field.
Sourcefn compute_key_hash(&self) -> Option<[u8; 16]>
fn compute_key_hash(&self) -> Option<[u8; 16]>
Computes the 16-byte KeyHash of this instance per XTypes 1.3
§7.6.8.4. None if HAS_KEY = false.
The default implementation uses Self::encode_key_holder_be +
Self::KEY_HOLDER_MAX_SIZE and delegates to
compute_key_hash.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".