Skip to main content

ReliableWriter

Struct ReliableWriter 

Source
pub struct ReliableWriter { /* private fields */ }
Expand description

A reliable writer with 0..N reader proxies.

Implementations§

Source§

impl ReliableWriter

Source

pub fn new(cfg: ReliableWriterConfig) -> Self

Creates an empty writer.

§Panics
  • cfg.fragment_size == 0
  • cfg.mtu < 20 (the RTPS header does not fit)
Source

pub fn guid(&self) -> Guid

GUID of the writer.

Source

pub fn set_emit_info_dst(&mut self, v: bool)

Enables INFO_DST(target-prefix) before each datagram (RTPS 2.5 §8.3.7). Needed for receivers that match directed submessages by full GUID (cyclone filtered VolatileSecure reader).

Source

pub fn reader_proxies(&self) -> &[ReaderProxy]

Read-only-Slice der registrierten Reader-Proxies.

Source

pub fn reader_proxy_count(&self) -> usize

Number of registered reader proxies.

Source

pub fn remove_samples_up_to(&mut self, up_to_exclusive: SequenceNumber) -> usize

Removes samples with SN < up_to_exclusive from the cache. Used by higher layers for lifespan expiry (Spec §2.2.3.16): expired samples disappear so that even late reader proxies no longer get them.

Source

pub fn cache(&self) -> &HistoryCache

History cache (read-only).

Source

pub fn set_cache_kind_and_max(&mut self, kind: HistoryKind, max_samples: usize)

Expert-only: sets the history kind + max_samples of the cache at runtime. Used by DcpsRuntime for the durability-backend replay burst (Spec §2.2.3.5) — the cache must hold all replay samples during the burst, then return to the user QoS.

Source

pub fn heartbeat_count(&self) -> i32

Number of HEARTBEATs sent.

Source

pub fn nackfrag_count(&self) -> i32

Number of NACK_FRAGs received.

Source

pub fn unknown_src_count(&self) -> u64

Number of ACKNACK/NACK_FRAG messages from unknown sources since writer start. Typical causes: misrouting on multicast, stale proxies after remove_reader_proxy, GUID spoofing.

Source

pub fn fragment_size(&self) -> u32

Current fragment-size configuration.

Source

pub fn set_fragmentation(&mut self, fragment_size: u32, mtu: usize)

Sets fragment size + MTU budget anew — called by the DCPS layer when the path MTU of the matched readers changes: if ALL readers run on the same host (loopback, MTU 65536), one datagram per sample suffices (LOOPBACK_FRAGMENT_SIZE); if a reader is remote, it stays at the Ethernet-safe DEFAULT_FRAGMENT_SIZE (otherwise an oversized datagram gets IP-fragmented on the 1500 path, and a lost IP fragment costs the whole sample).

§Panics

fragment_size == 0 or mtu < 20.

Source

pub fn all_samples_acknowledged(&self) -> bool

Checks whether all reader proxies have already acknowledged the currently highest sample SN in the cache. Returns true even if the cache is empty or no proxies exist (nothing to acknowledge).

Spec basis for DataWriter::wait_for_acknowledgments (OMG DDS 1.4 §2.2.2.4.2.22).

Source

pub fn add_reader_proxy(&mut self, proxy: ReaderProxy)

Adds a reader proxy. Idempotent: if a proxy with the same remote_reader_guid exists, it is replaced.

Sets last_heartbeat = None, so the next tick() immediately emits a heartbeat to all proxies (incl. the new one). RTPS §8.4.15.4: a freshly added ReaderProxy must get an opportunity to AckNack, otherwise it waits until the next periodic heartbeat round (default 1 s) — and for late-wired proxies (after cache inserts) this is the only way to catch up the early- inserted samples, since write_sample_with_datagrams only sends directly if the proxy is synchronous.

Source

pub fn remove_reader_proxy(&mut self, guid: Guid) -> Option<ReaderProxy>

Removes the proxy with the given GUID.

Source

pub fn write( &mut self, payload: &[u8], ) -> Result<Vec<OutboundDatagram>, WireError>

Writes a new sample and fans it out to all proxies.

Per proxy this produces (aggregated):

  • 1 DATA datagram if payload.len() <= fragment_size
  • N DATA_FRAG datagrams (one datagram per fragment, no mix)
§Errors

SN overflow, cache full, body too large.

Source

pub fn write_stamped( &mut self, payload: &[u8], source_timestamp: Option<HeTimestamp>, ) -> Result<Vec<OutboundDatagram>, WireError>

Like Self::write, but attaches a source timestamp (DDSI-RTPS §8.7.3): the writer prepends an INFO_TS submessage before each DATA so the reader can populate SampleInfo.source_timestamp and apply DESTINATION_ORDER = BY_SOURCE_TIMESTAMP. None ⇒ no INFO_TS.

§Errors

SN overflow, cache full, body too large.

Source

pub fn write_with_heartbeat( &mut self, payload: &[u8], now: Duration, ) -> Result<Vec<OutboundDatagram>, WireError>

D.5e phase 2: write + piggyback HEARTBEAT in one operation.

Cyclone DDS and FastDDS additionally send a HEARTBEAT on every write(), so the reader can trigger an ACKNACK immediately. Without the piggyback the reader must wait until the next periodic HB (default 100 ms) — which becomes the latency floor for a 1-in-flight roundtrip.

This method is a superset of Self::write: it emits all DATA datagrams and appends a HEARTBEAT datagram per matched reader proxy. last_heartbeat = now is set so that tick() does not fire twice.

§Errors

Wire encode error.

Source

pub fn write_with_heartbeat_stamped( &mut self, payload: &[u8], now: Duration, source_timestamp: Option<HeTimestamp>, ) -> Result<Vec<OutboundDatagram>, WireError>

Like Self::write_with_heartbeat, with a source timestamp (emits INFO_TS before each DATA — see Self::write_stamped).

§Errors

Wire encode error.

Source

pub fn tick( &mut self, now: Duration, ) -> Result<Vec<OutboundDatagram>, WireError>

Tick-Event: HEARTBEATs + Resends + NACK_FRAG-Responses, aggregiert.

§Errors

Wire-encode error.

Source

pub fn handle_acknack( &mut self, src_guid: Guid, base: SequenceNumber, requested: impl IntoIterator<Item = SequenceNumber>, )

Processes a received ACKNACK from src_guid. Unknown sender → no-op.

Source

pub fn handle_nackfrag(&mut self, src_guid: Guid, nf: &NackFragSubmessage)

Processes a received NACK_FRAG from src_guid.

Source

pub fn write_lifecycle( &mut self, key_hash: [u8; 16], status_bits: u32, ) -> Result<Vec<OutboundDatagram>, WireError>

Sends a lifecycle marker (dispose/unregister) to all matched readers. Allocates a new sequence number, persists a CacheChange with the corresponding ChangeKind and builds a DATA with key hash + StatusInfo per reader proxy.

status_bits is the OR combination of the desired bits from crate::inline_qos::status_info:

  • DISPOSED: NotAliveDisposed
  • UNREGISTERED: NotAliveUnregistered
  • DISPOSED | UNREGISTERED: NotAliveDisposedUnregistered
§Errors

Wire encode error or sequence-number overflow.

Trait Implementations§

Source§

impl Clone for ReliableWriter

Source§

fn clone(&self) -> ReliableWriter

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 ReliableWriter

Source§

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

Formats the value using the given formatter. Read more

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.