GpsdClientCore

Struct GpsdClientCore 

Source
pub struct GpsdClientCore<Stream, Proto> { /* private fields */ }
Expand description

Core implementation of an asynchronous GPSD client

This struct provides the fundamental functionality for asynchronous communication with a GPSD server. It handles protocol negotiation, message serialization/deserialization, and maintains the connection state.

§Type Parameters

  • Stream - The underlying async I/O stream type (e.g., TcpStream)
  • Proto - The GPSD protocol version implementation

Implementations§

Source§

impl<Stream, Proto> GpsdClientCore<Stream, Proto>
where Proto: GpsdJsonProtocol,

Source

pub async fn open(stream: Stream) -> Result<Self>
where Stream: AsyncRead + AsyncWrite + Unpin,

Opens a new GPSD client connection using the provided async stream

This method initializes the client with the given async I/O stream and performs protocol version negotiation with the GPSD server.

§Arguments
  • stream - The async I/O stream for communication with GPSD
§Returns
  • Ok(client) - Successfully connected and negotiated protocol
  • Err(_) - Connection or protocol negotiation failed
Source§

impl<Proto> GpsdClientCore<Compat<TcpStream>, Proto>
where Proto: GpsdJsonProtocol,

Source

pub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<Self>

Connects to a GPSD server over TCP asynchronously

Creates an async TCP connection to the specified address and initializes a GPSD client with protocol negotiation.

§Arguments
  • addr - Socket address of the GPSD server (e.g., “127.0.0.1:2947”)
§Example
let client = GpsdClient::connect("127.0.0.1:2947").await?;
Source§

impl<Stream> GpsdClientCore<Stream, V3>
where Stream: AsyncRead + AsyncWrite + Unpin,

Source

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

Requests version information from the GPSD server

Returns details about the GPSD server version, protocol version, and capabilities.

Source

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

Lists all GPS devices known to the GPSD server

Returns information about each connected GPS receiver including device paths, driver information, and current status.

Source

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

Gets information about the currently active GPS device

Returns detailed information about the device currently being used for GPS data.

Source

pub async fn watch(&mut self) -> Result<(Watch, DeviceList)>

Enables data streaming from GPSD with default settings

Returns the current watch configuration and list of available devices. After calling this method, GPS data will be streamed from the server.

Source

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

Polls for the current GPS fix data

Returns the most recent GPS fix information available from all active devices.

Source

pub async fn watch_mode(&mut self, enable: bool) -> Result<()>

Enables or disables data streaming mode

§Arguments
  • enable - true to start streaming, false to stop
Source

pub async fn stream<Format: StreamFormat>( self, opts: StreamOptions<Format>, ) -> Result<GpsdDataStream<Stream, V3, Format>>

Starts a data stream with the specified format and options

This method consumes the client and returns a stream iterator that yields GPS data in the requested format.

§Arguments
  • opts - Stream configuration options
§Example
let mut stream = client.stream(StreamOptions::json()).await?;
while let Some(msg) = stream.next().await {
    println!("GPS data: {:?}", msg?);
}

Trait Implementations§

Source§

impl<Stream: Debug, Proto: Debug> Debug for GpsdClientCore<Stream, Proto>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Stream, Proto> Freeze for GpsdClientCore<Stream, Proto>
where Stream: Freeze,

§

impl<Stream, Proto> RefUnwindSafe for GpsdClientCore<Stream, Proto>
where Stream: RefUnwindSafe, Proto: RefUnwindSafe,

§

impl<Stream, Proto> Send for GpsdClientCore<Stream, Proto>
where Stream: Send, Proto: Send,

§

impl<Stream, Proto> Sync for GpsdClientCore<Stream, Proto>
where Stream: Sync, Proto: Sync,

§

impl<Stream, Proto> Unpin for GpsdClientCore<Stream, Proto>
where Proto: Unpin, Stream: Unpin,

§

impl<Stream, Proto> UnwindSafe for GpsdClientCore<Stream, Proto>
where Stream: UnwindSafe, Proto: UnwindSafe,

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, 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.