Skip to main content

SeedLinkClient

Struct SeedLinkClient 

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

Async SeedLink client for connecting to seismic data servers.

Implements the SeedLink v3/v4 protocol state machine: ConnectedConfiguredStreamingDisconnected.

§Example

use seedlink_rs_client::SeedLinkClient;

let mut client = SeedLinkClient::connect("rtserve.iris.washington.edu:18000").await?;
client.station("ANMO", "IU").await?;
client.select("BHZ").await?;
client.data().await?;
client.end_stream().await?;

while let Some(frame) = client.next_frame().await? {
    println!("seq={}, len={}", frame.sequence(), frame.payload().len());
}

Implementations§

Source§

impl SeedLinkClient

Source

pub async fn connect(addr: &str) -> Result<Self>

Connect to a SeedLink server with default configuration.

Performs TCP connect, sends HELLO, and negotiates v4 if supported. On success the client is in ClientState::Connected.

Source

pub async fn connect_with_config( addr: &str, config: ClientConfig, ) -> Result<Self>

Connect to a SeedLink server with custom ClientConfig.

Performs TCP connect, sends HELLO, and optionally negotiates v4. On success the client is in ClientState::Connected.

Source

pub fn version(&self) -> ProtocolVersion

Returns the negotiated protocol version (V3 or V4).

Source

pub fn server_info(&self) -> &ServerInfo

Returns information about the connected server (software, version, capabilities).

Source

pub fn state(&self) -> ClientState

Returns the current client state.

Source

pub fn config(&self) -> &ClientConfig

Returns the configuration used for this connection.

Source

pub async fn station(&mut self, station: &str, network: &str) -> Result<()>

Select a station and network for data subscription.

Requires state Connected or Configured. Transitions to Configured. Server must reply OK; returns ClientError::ServerError on ERROR.

Source

pub async fn select(&mut self, pattern: &str) -> Result<()>

Select channels within the current station subscription.

pattern is a SeedLink channel selector (e.g., "BHZ", "??.BHZ"). Requires state Connected or Configured. Transitions to Configured.

Source

pub async fn data(&mut self) -> Result<()>

Arm the current station subscription with DATA (stream from beginning).

This does NOT start streaming — call end_stream() or fetch() after arming all stations. Requires state Configured. State stays Configured.

Source

pub async fn data_from(&mut self, sequence: SequenceNumber) -> Result<()>

Arm the current station subscription with DATA, resuming from sequence.

Requires state Configured. State stays Configured.

Source

pub async fn time_window( &mut self, start: &str, end: Option<&str>, ) -> Result<()>

Arm the current station subscription with a time window (v3 only).

Sends TIME start [end] to request data within a specific time range. Requires state Configured. State stays Configured.

Source

pub async fn end_stream(&mut self) -> Result<()>

Send END to trigger continuous binary streaming.

The server begins sending frames immediately with no text response. Requires state Configured. Transitions to Streaming.

Source

pub async fn fetch(&mut self) -> Result<()>

Send FETCH to stream buffered data then close (v3 only).

Unlike end_stream(), FETCH delivers only what the server has buffered, then the server closes the connection. Requires state Configured. Transitions to Streaming.

Source

pub async fn fetch_from(&mut self, sequence: SequenceNumber) -> Result<()>

Send FETCH resuming from sequence (v3 only).

Requires state Configured. Transitions to Streaming.

Source

pub async fn next_frame(&mut self) -> Result<Option<OwnedFrame>>

Read the next SeedLink frame from the server.

Returns Ok(Some(frame)) on success, Ok(None) on clean EOF (server closed connection), or Err on protocol/timeout errors. On EOF, state transitions to Disconnected. Requires state Streaming.

Source

pub fn into_stream(self) -> impl Stream<Item = Result<OwnedFrame>>

Consume this client and return a Stream of frames.

The client must be in Streaming state. The stream yields Ok(OwnedFrame) per frame and ends with None on EOF.

Source

pub async fn info(&mut self, level: InfoLevel) -> Result<Vec<OwnedFrame>>

Request server information at the given detail level.

Returns a vec of INFO response frames (typically XML payloads). Can be called in any state.

Source

pub async fn bye(&mut self) -> Result<()>

Send BYE and close the connection.

Transitions to Disconnected. Can be called in any state.

Source

pub fn last_sequence( &self, network: &str, station: &str, ) -> Option<SequenceNumber>

Returns the last received sequence number for a given network/station pair.

Returns None if no frames have been received for that station.

Source

pub fn sequences(&self) -> &HashMap<StationKey, SequenceNumber>

Returns a reference to all tracked network/station → sequence mappings.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more