GpsdClientCore

Struct GpsdClientCore 

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

Core implementation of a blocking GPSD client

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

§Type Parameters

  • Stream - The underlying 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 fn open(stream: Stream) -> Result<Self>
where Stream: Read + Write,

Opens a new GPSD client connection using the provided stream

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

§Arguments
  • stream - The 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<TcpStream, Proto>
where Proto: GpsdJsonProtocol,

Source

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

Connects to a GPSD server over TCP

Creates a 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”)
§Returns
  • Ok(client) - Successfully connected to GPSD
  • Err(_) - Connection failed or protocol negotiation failed
§Example
let client = GpsdClient::connect("127.0.0.1:2947").unwrap();
Source§

impl<Stream> GpsdClientCore<Stream, V3>
where Stream: Read + Write,

Source

pub 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 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 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 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 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 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 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 stream = client.stream(StreamOptions::json()).unwrap();

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
Source§

impl<Proto> TryFrom<TcpStream> for GpsdClientCore<TcpStream, Proto>
where Proto: GpsdJsonProtocol,

Source§

type Error = GpsdJsonError

The type returned in the event of a conversion error.
Source§

fn try_from(stream: TcpStream) -> Result<Self>

Performs the conversion.

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 Stream: Unpin, Proto: 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.