pub struct ReliableWriter { /* private fields */ }Expand description
A reliable writer with 0..N reader proxies.
Implementations§
Source§impl ReliableWriter
impl ReliableWriter
Sourcepub fn new(cfg: ReliableWriterConfig) -> Self
pub fn new(cfg: ReliableWriterConfig) -> Self
Sourcepub fn set_emit_info_dst(&mut self, v: bool)
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).
Sourcepub fn reader_proxies(&self) -> &[ReaderProxy]
pub fn reader_proxies(&self) -> &[ReaderProxy]
Read-only-Slice der registrierten Reader-Proxies.
Sourcepub fn reader_proxy_count(&self) -> usize
pub fn reader_proxy_count(&self) -> usize
Number of registered reader proxies.
Sourcepub fn remove_samples_up_to(&mut self, up_to_exclusive: SequenceNumber) -> usize
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.
Sourcepub fn cache(&self) -> &HistoryCache
pub fn cache(&self) -> &HistoryCache
History cache (read-only).
Sourcepub fn set_cache_kind_and_max(&mut self, kind: HistoryKind, max_samples: usize)
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.
Sourcepub fn heartbeat_count(&self) -> i32
pub fn heartbeat_count(&self) -> i32
Number of HEARTBEATs sent.
Sourcepub fn nackfrag_count(&self) -> i32
pub fn nackfrag_count(&self) -> i32
Number of NACK_FRAGs received.
Sourcepub fn unknown_src_count(&self) -> u64
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.
Sourcepub fn fragment_size(&self) -> u32
pub fn fragment_size(&self) -> u32
Current fragment-size configuration.
Sourcepub fn set_fragmentation(&mut self, fragment_size: u32, mtu: usize)
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.
Sourcepub fn all_samples_acknowledged(&self) -> bool
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).
Sourcepub fn add_reader_proxy(&mut self, proxy: ReaderProxy)
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.
Sourcepub fn remove_reader_proxy(&mut self, guid: Guid) -> Option<ReaderProxy>
pub fn remove_reader_proxy(&mut self, guid: Guid) -> Option<ReaderProxy>
Removes the proxy with the given GUID.
Sourcepub fn write(
&mut self,
payload: &[u8],
) -> Result<Vec<OutboundDatagram>, WireError>
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.
Sourcepub fn write_stamped(
&mut self,
payload: &[u8],
source_timestamp: Option<HeTimestamp>,
) -> Result<Vec<OutboundDatagram>, WireError>
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.
Sourcepub fn write_with_heartbeat(
&mut self,
payload: &[u8],
now: Duration,
) -> Result<Vec<OutboundDatagram>, WireError>
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.
Sourcepub fn write_with_heartbeat_stamped(
&mut self,
payload: &[u8],
now: Duration,
source_timestamp: Option<HeTimestamp>,
) -> Result<Vec<OutboundDatagram>, WireError>
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.
Sourcepub fn handle_acknack(
&mut self,
src_guid: Guid,
base: SequenceNumber,
requested: impl IntoIterator<Item = SequenceNumber>,
)
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.
Sourcepub fn handle_nackfrag(&mut self, src_guid: Guid, nf: &NackFragSubmessage)
pub fn handle_nackfrag(&mut self, src_guid: Guid, nf: &NackFragSubmessage)
Processes a received NACK_FRAG from src_guid.
Sourcepub fn write_lifecycle(
&mut self,
key_hash: [u8; 16],
status_bits: u32,
) -> Result<Vec<OutboundDatagram>, WireError>
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
impl Clone for ReliableWriter
Source§fn clone(&self) -> ReliableWriter
fn clone(&self) -> ReliableWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more