Skip to main content

Crate rustorb_dds

Crate rustorb_dds 

Source
Expand description

A DDS 1.4 implementation in Rust: the DCPS API (domain participants, topics, publishers, subscribers, data writers and data readers) over DDSI-RTPS 2.5 (rustorb_rtps).

Sample types implement TopicType from rustorb-typesupport, which the IDL compiler generates (rustorb-idl -brust -Wbdds); a hand-written implementation works the same way. Samples of types known only at run time are DynamicData.

use std::time::Duration;
use rustorb_dds::DomainParticipant;

let participant = DomainParticipant::new(0)?;
let topic = participant.create_topic::<Greeting>("hello")?;
let writer = participant.create_publisher()?.create_datawriter(&topic)?;
let reader = participant.create_subscriber()?.create_datareader(&topic)?;
writer.write(&hello)?;
if reader.wait_for_data(Duration::from_secs(1)) {
    for sample in reader.take() {
        // `None` when the sample only tells of a change in the state
        // of its instance (disposed, no more writers).
        let _greeting: Option<Greeting> = sample.data;
    }
}

What works now (rustorb/rustorb#111, stages D1 and part of D2): discovery with SPDP and SEDP, and RELIABLE or BEST_EFFORT, VOLATILE or TRANSIENT_LOCAL writers and readers (and TRANSIENT and PERSISTENT ones, whose samples outlive the writer), in partitions (with wildcards), over UDPv4. Endpoints whose QoS do not match are counted in the incompatible QoS statuses; readers reject samples beyond their RESOURCE_LIMITS. LIVELINESS (with the Writer Liveliness Protocol) and DEADLINE are kept and reported in statuses. A thread can wait for samples or status changes on a WaitSet, with a StatusCondition, a ReadCondition or a GuardCondition, or have them handed to a DataReaderListener or DataWriterListener; a status that the endpoint’s listener does not take goes to the PublisherListener or SubscriberListener (with on_data_on_readers first), then to the DomainParticipantListener (DDS 1.4, 2.2.4.3). A participant that is deleted tells the others. Keyed types have instances: writers register, write, dispose and unregister them; readers keep a history per instance with its states (DDS 1.4, 2.2.2.5.1). Samples larger than a datagram go as DATA_FRAG, and lost fragments are repaired. Samples are written in XCDR1. Writers and readers in the same participant are matched with each other too.

Data flows with ROS 2 nodes too (the ros2 example).

A ContentFilteredTopic (DDS 1.4, 2.2.2.3.3) gives its readers only the samples of its related topic that pass a filter expression (DDS 1.4, Annex B, see ContentFilter); readers are created for a TopicDescription, a topic or a content filtered topic.

DDS-XTypes (D3, in progress): a type registered with DomainParticipant::register_type (its DescribeType is written by rustorb-idl -Wbxtypes) is announced with its TypeInformation, and its endpoints match others by type assignability (DataReaderQos::type_consistency) instead of by type name. Writers can write XCDR2 (DataWriterQos::data_representation). Topics count the endpoints whose types are not consistent with theirs (Topic::inconsistent_topic_status). When a remote endpoint’s type differs from the local one, the participant gets its TypeObjects from the remote participant with the TypeLookup service (DDS-XTypes 1.3, 7.6.3.3) before it decides, and answers such requests for its own types (DomainParticipant::learnt_types, the evolve example).

A program can also handle topics whose types it was not built with (DDS-XTypes 1.3, 7.5.2): DomainParticipant::discover_topic_type gets the type of a remote endpoint of a topic as a DynamicType, by TypeLookup, and DomainParticipant::create_dynamic_topic makes a topic of it (or of a type built at run time) whose writers and readers write and read DynamicData (the dynamic example).

Modules§

data_representation
Data representation identifiers (DDS-XTypes 1.3, 7.6.3.1.1).
rpc
Requests and replies over DDS (DDS-RPC 1.0): a Requester sends requests on a request topic and gets the replies to them on a reply topic; a Replier takes the requests and answers each one.

Structs§

AnyDataReader
A data reader of any type, as given to the listener of its subscriber or participant (AnyDataReader of the C++ PSM).
AnyDataWriter
A data writer of any type, as given to the listener of its publisher or participant (AnyDataWriter of the C++ PSM).
ContentFilter
A filter expression (DDS 1.4, Annex B), checked against a type: a DDSSQL content filter, with its parameters.
ContentFilteredTopic
A topic whose readers get only the samples of its related topic that pass a filter (DDS 1.4, 2.2.2.3.3): a filter expression (DDS 1.4, Annex B, see ContentFilter) with parameters, which can change.
DataReader
A DDS data reader (DDS 1.4, 2.2.2.5.3) of samples of type T: a TopicType, or DynamicData for a topic of a type known at run time (a DynamicDataReader, DDS-XTypes 1.3, 7.5.2.12).
DataReaderQos
The QoS of a crate::DataReader that can be set for now.
DataWriter
A DDS data writer (DDS 1.4, 2.2.2.4.2) of samples of type T: a TopicType, or DynamicData for a topic of a type known at run time (a DynamicDataWriter, DDS-XTypes 1.3, 7.5.2.12).
DataWriterQos
The QoS of a crate::DataWriter that can be set for now.
DeadlineMissedStatus
OFFERED_DEADLINE_MISSED of a writer or REQUESTED_DEADLINE_MISSED of a reader (DDS 1.4, 2.2.4.1): DEADLINE periods that passed without a sample of an instance, one count for each period and instance.
DiscoveredEndpoint
A writer or reader of another participant, as discovered with SEDP (DDSI-RTPS 2.5, 8.5.4): part of the PublicationBuiltinTopicData or SubscriptionBuiltinTopicData of DDS 1.4 (2.2.5).
DomainParticipant
A DDS domain participant (DDS 1.4, 2.2.2.2.1): the entry point that creates topics, publishers and subscribers in one domain.
DurabilityService
The DURABILITY_SERVICE of a TRANSIENT or PERSISTENT writer (DDS 1.4, 2.2.3.5): what the participant keeps of the writer’s samples once the writer is deleted, and for how long it keeps a disposed instance.
DynamicData
A value of a DynamicType (DynamicData, 7.5.2.11).
DynamicDataFactory
Makes DynamicData (DynamicDataFactory, 7.5.2.10).
DynamicType
A type known at run time (DynamicType, 7.5.2.8): a Type of the type system model, with the introspection operations of the specification. Cloning is cheap; named types are shared.
DynamicTypeBuilder
Builds a DynamicType (DynamicTypeBuilder, 7.5.2.9).
DynamicTypeBuilderFactory
Makes DynamicTypeBuilders (DynamicTypeBuilderFactory, 7.5.2.2).
GuardCondition
A condition whose trigger value the application sets (DDS 1.4, 2.2.2.1.8): to wake a thread waiting on a WaitSet.
Guid
A globally unique identifier of an entity (DDSI-RTPS 2.5, 9.3.1.5).
GuidPrefix
The 12-octet prefix shared by the GUIDs of all entities of one participant (DDSI-RTPS 2.5, 9.3.1.1).
IncompatibleQosStatus
OFFERED_INCOMPATIBLE_QOS of a writer or REQUESTED_INCOMPATIBLE_QOS of a reader (DDS 1.4, 2.2.4.1): endpoints of the same topic, type and partition that did not match because of their QoS.
InconsistentTopicStatus
INCONSISTENT_TOPIC of a topic (DDS 1.4, 2.2.4.1): writers or readers of the topic found in other participants whose types are not consistent with the local ones (DDS-XTypes 1.3, 7.6.3.4.2).
InstanceHandle
Identifies an instance: its key hash (DDSI-RTPS 2.5, 9.6.4.8). Every writer and reader of a topic gives an instance the same handle. A type without key has one instance.
InstanceStateMask
A set of InstanceStates (InstanceStateMask).
Liveliness
The LIVELINESS of a writer or a reader (DDS 1.4, 2.2.3.11).
LivelinessChangedStatus
LIVELINESS_CHANGED of a reader (DDS 1.4, 2.2.4.1): how many of its matched writers are alive, and how many are not.
LivelinessLostStatus
LIVELINESS_LOST of a writer (DDS 1.4, 2.2.4.1): times it failed to assert its liveliness within its lease, so that readers took it as no longer alive.
MatchedStatus
PUBLICATION_MATCHED of a writer or SUBSCRIPTION_MATCHED of a reader (DDS 1.4, 2.2.4.1): the endpoints it matched.
MaxSamples
The reads and takes of a DataReader limited to a number of samples (DataReader::max_samples).
ParticipantConfig
Settings of a DomainParticipant.
Publisher
A DDS publisher (DDS 1.4, 2.2.2.4.1): creates data writers.
PublisherQos
The QoS of a crate::Publisher.
QosPolicyCount
How many times one policy made endpoints incompatible.
QosPolicyId
QosPolicyId_t (DDS 1.4, 2.3.3): which policy made a writer and a reader incompatible.
ReadCondition
A condition on the samples of a reader (DDS 1.4, 2.2.2.5.8): true while the reader has a sample whose states pass its filter. Made with DataReader::create_readcondition; reading or taking with DataReader::read_w_condition or take_w_condition selects the same samples.
ReadLoan
A sample read without a copy: in the shared memory of the writer that loaned it, held there until this is dropped, or a value of its own (a sample that was serialized).
Reliability
The RELIABILITY of a writer or a reader (DDS 1.4, 2.2.3.14).
ResourceLimits
The RESOURCE_LIMITS of a writer or a reader (DDS 1.4, 2.2.3.19). None is LENGTH_UNLIMITED, the default.
Sample
A sample with its information.
SampleIdentity
The identity of a sample: its writer and its sequence number (SampleIdentity, DDS-RPC 1.0, 7.5.1.1.1). A reply carries that of its request in-line, as PID_RELATED_SAMPLE_IDENTITY (7.8.2).
SampleInfo
Information about a sample (DDS 1.4 SampleInfo, 2.2.2.5.5).
SampleLostStatus
SAMPLE_LOST of a reader (DDS 1.4, 2.2.4.1): samples it never got.
SampleRejectedStatus
SAMPLE_REJECTED of a reader (DDS 1.4, 2.2.4.1): samples dropped because of its RESOURCE_LIMITS.
SampleStateMask
A set of SampleStates (SampleStateMask).
SequenceNumber
A 64-bit signed sequence number (DDSI-RTPS 2.5, 8.3.5.4 and 9.3.2.10).
StateFilter
Which samples a read or take returns: those whose states are in all three masks. The default takes any.
StatusCondition
The condition of an entity’s communication statuses (DDS 1.4, 2.2.2.1.9): true when one of its enabled statuses has changed since it was last read (get_status_changes() & get_enabled_statuses()).
StatusMask
A set of communication status kinds (DDS 1.4 StatusMask, 2.2.4.1), with the values of the IDL PSM (2.3.3).
Subscriber
A DDS subscriber (DDS 1.4, 2.2.2.5.1): creates data readers.
SubscriberQos
The QoS of a crate::Subscriber.
Time
A point in time in NTP format: seconds + fraction / 2^32 (DDSI-RTPS 2.5, 9.3.2.1 and 9.3.2.2).
Topic
A DDS topic (DDS 1.4, 2.2.2.3.2): a name and the type of its samples, which are of Rust type T: a TopicType the program was built with, or DynamicData of a type known at run time (DomainParticipant::create_dynamic_topic). Writers and readers match by topic name and type name, or by type assignability for registered types.
TypeConsistency
TypeConsistencyEnforcementQosPolicy (7.6.3.4), a policy of readers.
ViewStateMask
A set of ViewStates (ViewStateMask).
WaitSet
A set of conditions a thread waits on (DDS 1.4, 2.2.2.1.7): wait returns when one of them is true.
WriteLoan
A sample loaned to a writer to fill: in shared memory when the writer has a pool, else on the heap. It holds zeros, or (a slot used again) an earlier sample of the writer; it is published with DataWriter::write_loaned, and returned unwritten when dropped.
WriteParams
The parameters of DataWriter::write_w_params.
WriterDataLifecycle
The WRITER_DATA_LIFECYCLE of a writer (DDS 1.4, 2.2.3.21).

Enums§

Condition
A condition to attach to a WaitSet (DDS 1.4 Condition, 2.2.2.1.6).
DurabilityKind
DurabilityQosPolicyKind, in the order of the DDS enum, which is also the order used to compare an offered and a requested kind (DDS 1.4, 2.2.3.4).
Error
Why a DCPS operation failed.
History
The HISTORY of a writer or a reader (DDS 1.4, 2.2.3.18): how many samples it keeps.
InstanceState
The state of an instance (2.2.2.5.1.3).
LivelinessKind
LivelinessQosPolicyKind, in the order of the DDS enum, which is also the order used to compare an offered and a requested kind (DDS 1.4, 2.2.3.11).
ReliabilityKind
ReliabilityQosPolicyKind. On the wire it is ReliabilityKind_t: BEST_EFFORT = 1, RELIABLE = 2 (DDSI-RTPS 2.5, 9.3.2 and Table 9.18 note 3), not the DDS enum ordinal.
SampleRejectedReason
Why a reader rejected a sample.
SampleState
Whether a sample was read before (DDS 1.4, 2.2.2.5.1.2).
TypeConsistencyKind
TypeConsistencyKind (7.6.3.4.1).
ViewState
Whether the reader has seen the instance before (2.2.2.5.1.8).

Constants§

DATA_REPRESENTATION_QOS_POLICY_ID
DATA_REPRESENTATION_QOS_POLICY_ID (DDS-XTypes 1.3, Annex D).
MEMBER_ID_INVALID
MEMBER_ID_INVALID: names the value of a DynamicData itself, rather than one of its members (7.5.2.11.1).
VENDOR_ID
The vendor id sent in RTPS headers. rustorb has no vendor id from the OMG yet, so this is VENDORID_UNKNOWN (DDSI-RTPS 2.5, 8.3.3.1.3).

Traits§

DataReaderListener
The listener of a DataReader (DataReaderListener, DDS 1.4, 2.2.4.3.9): called when one of its statuses changes. Each method does nothing unless implemented.
DataWriterListener
The listener of a DataWriter (DataWriterListener, DDS 1.4, 2.2.4.3.8): called when one of its statuses changes, as for DataReaderListener. Each method does nothing unless implemented.
DescribeType
A Rust type that knows its DDS-XTypes description. rustorb-idl writes impls of it with -Wbxtypes.
DomainParticipantListener
The listener of a DomainParticipant (DomainParticipantListener, DDS 1.4, 2.2.2.2.3): what the listeners of its publishers, subscribers, topics, writers and readers do not take. It has the methods of PublisherListener, SubscriberListener and TopicListener; implement those (empty impl blocks for the ones not needed) and this.
PlainType
A type whose samples can be loaned: one of a fixed size, whose value in memory is its serialized form.
PublisherListener
The listener of a Publisher (PublisherListener, DDS 1.4, 2.2.2.4.3): the statuses of its writers that their own listeners do not take. Each method does nothing unless implemented.
SubscriberListener
The listener of a Subscriber (SubscriberListener, DDS 1.4, 2.2.2.5.6): DATA_ON_READERS, and the statuses of its readers that their own listeners do not take. Each method does nothing unless implemented.
TopicDescription
What readers can be created for (TopicDescription, DDS 1.4, 2.2.2.3.1): a Topic or a ContentFilteredTopic.
TopicListener
The listener of a Topic (TopicListener, DDS 1.4, 2.2.2.3.5). Each method does nothing unless implemented.
TopicType
A type a DDS DataWriter publishes: a generated struct or union that is not @nested (DDS-XTypes 7.3.1.2.1.7 and 7.3.1.2.1.16).

Type Aliases§

Result
The result of a DCPS operation.