pub struct ReconnectingClient { /* private fields */ }Expand description
A wrapper around SeedLinkClient that automatically reconnects on disconnect.
Records all subscription steps (STATION, SELECT, DATA, TIME) and replays them on reconnect. On resume, replaces DATA with DATA-from-sequence using the last tracked sequence numbers.
§Deduplication guarantee
SeedLink servers may resend the last frame at the requested sequence number
when resuming with DATA seq. This client automatically deduplicates frames
after reconnect: any frame whose sequence number is ≤ the last tracked
sequence for its station is silently dropped. Downstream consumers are
guaranteed to never see duplicate frames.
Implementations§
Source§impl ReconnectingClient
impl ReconnectingClient
Sourcepub async fn connect(addr: &str) -> Result<Self>
pub async fn connect(addr: &str) -> Result<Self>
Connect to a SeedLink server with reconnect support using default configs.
Sourcepub async fn connect_with_config(
addr: &str,
config: ClientConfig,
reconnect: ReconnectConfig,
) -> Result<Self>
pub async fn connect_with_config( addr: &str, config: ClientConfig, reconnect: ReconnectConfig, ) -> Result<Self>
Connect with custom client and reconnect configuration.
Sourcepub async fn station(&mut self, station: &str, network: &str) -> Result<()>
pub async fn station(&mut self, station: &str, network: &str) -> Result<()>
Select a station and network. Records the step for reconnect replay.
Sourcepub async fn select(&mut self, pattern: &str) -> Result<()>
pub async fn select(&mut self, pattern: &str) -> Result<()>
Select channels. Records the step for reconnect replay.
Sourcepub async fn data(&mut self) -> Result<()>
pub async fn data(&mut self) -> Result<()>
Arm with DATA. Records the step for reconnect replay.
Sourcepub async fn data_from(&mut self, sequence: SequenceNumber) -> Result<()>
pub async fn data_from(&mut self, sequence: SequenceNumber) -> Result<()>
Arm with DATA from a specific sequence. Records the step for reconnect replay.
Sourcepub async fn time_window(
&mut self,
start: &str,
end: Option<&str>,
) -> Result<()>
pub async fn time_window( &mut self, start: &str, end: Option<&str>, ) -> Result<()>
Arm with TIME window. Records the step for reconnect replay.
Sourcepub async fn end_stream(&mut self) -> Result<()>
pub async fn end_stream(&mut self) -> Result<()>
Send END to start streaming. Does not record (replayed automatically).
Sourcepub async fn next_frame(&mut self) -> Result<Option<OwnedFrame>>
pub async fn next_frame(&mut self) -> Result<Option<OwnedFrame>>
Read the next frame, automatically reconnecting on EOF.
Returns Ok(Some(frame)) on success, Ok(None) when the stream truly ends
(max attempts exhausted or server sends clean EOF after reconnect),
or Err on non-recoverable errors.
Frames with sequence ≤ the last tracked sequence for their station are silently dropped (deduplication after reconnect).
Sourcepub fn into_stream(self) -> impl Stream<Item = Result<OwnedFrame>>
pub fn into_stream(self) -> impl Stream<Item = Result<OwnedFrame>>
Consume this client and return a Stream of frames with auto-reconnect.
Duplicate frames after reconnect are automatically filtered out.
Sourcepub fn last_sequence(
&self,
network: &str,
station: &str,
) -> Option<SequenceNumber>
pub fn last_sequence( &self, network: &str, station: &str, ) -> Option<SequenceNumber>
Returns the last received sequence number for a given network/station pair.
Sourcepub fn sequences(&self) -> &HashMap<StationKey, SequenceNumber>
pub fn sequences(&self) -> &HashMap<StationKey, SequenceNumber>
Returns a reference to all tracked sequences.