NtripClient

Struct NtripClient 

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

NTRIP client for streaming corrections from a caster. Supports both v1 (ICY) and v2 (HTTP/1.1) protocols.

Implementations§

Source§

impl NtripClient

Source

pub fn new(config: NtripConfig) -> Result<Self, Error>

Create a new NTRIP client with the given configuration.

Source

pub async fn connect(&mut self) -> Result<(), Error>

Connect to the NTRIP caster and start streaming.

For NTRIP v2, consider using connect_with_gga() to send an initial position in the request headers for faster VRS/nearest-base selection.

Source

pub async fn connect_with_gga( &mut self, initial_gga: Option<&GgaSentence>, ) -> Result<(), Error>

Connect to the NTRIP caster with an optional initial GGA position.

For NTRIP v2, the GGA sentence is sent in the Ntrip-GGA header, allowing the caster to select the appropriate VRS or nearest base immediately, without waiting for a post-connection GGA report.

For NTRIP v1, the initial_gga is ignored (GGA must be sent post-connection).

Source

pub async fn read_chunk(&mut self, buf: &mut [u8]) -> Result<usize, Error>

Read a chunk of RTCM data from the stream with timeout. Automatically handles chunked transfer encoding for NTRIP v2.

§Reconnection Behavior

If automatic reconnection is enabled (default: 3 attempts), this method will attempt to reconnect on timeout or disconnect errors before returning an error to the caller.

Important: When reconnection is enabled, this method may block for up to (max_reconnect_attempts × reconnect_delay_ms) + connection_timeout milliseconds while attempting to restore the connection. During this time:

  • The original error (timeout/disconnect) is not immediately returned
  • If a previous GGA position was set (via send_gga() or connect_with_gga()), it will be automatically resent after successful reconnection

To disable this behavior, use config.without_reconnect().

Source

pub fn is_connected(&self) -> bool

Check if connected.

Source

pub fn disconnect(&mut self)

Disconnect from the caster.

Source

pub async fn send_gga(&mut self, gga: &GgaSentence) -> Result<(), Error>

Send a GGA position report to the caster on the existing stream.

Source

pub fn config(&self) -> &NtripConfig

Get the configuration.

Source

pub async fn get_sourcetable(config: &NtripConfig) -> Result<Sourcetable, Error>

Fetch the sourcetable from the NTRIP caster.

This is a one-shot operation that connects, retrieves the sourcetable, and disconnects. It does not affect the current streaming connection.

Trait Implementations§

Source§

impl Drop for NtripClient

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> 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