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,
impl<Stream, Proto> GpsdClientCore<Stream, Proto>where
Proto: GpsdJsonProtocol,
Sourcepub async fn open(stream: Stream) -> Result<Self>
pub async fn open(stream: Stream) -> Result<Self>
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 protocolErr(_)- Connection or protocol negotiation failed
Source§impl<Proto> GpsdClientCore<Compat<TcpStream>, Proto>where
Proto: GpsdJsonProtocol,
impl<Proto> GpsdClientCore<Compat<TcpStream>, Proto>where
Proto: GpsdJsonProtocol,
Sourcepub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<Self>
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>
impl<Stream> GpsdClientCore<Stream, V3>
Sourcepub async fn version(&mut self) -> Result<Version>
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.
Sourcepub async fn devices(&mut self) -> Result<DeviceList>
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.
Sourcepub async fn device(&mut self) -> Result<Device>
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.
Sourcepub async fn watch(&mut self) -> Result<(Watch, DeviceList)>
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.
Sourcepub async fn poll(&mut self) -> Result<Poll>
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.
Sourcepub async fn watch_mode(&mut self, enable: bool) -> Result<()>
pub async fn watch_mode(&mut self, enable: bool) -> Result<()>
Sourcepub async fn stream<Format: StreamFormat>(
self,
opts: StreamOptions<Format>,
) -> Result<GpsdDataStream<Stream, V3, Format>>
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?);
}