gpsd_json/
lib.rs

1//! # gpsd-json
2//!
3//! A Rust library for interfacing with GPSD (GPS Service Daemon) using its JSON protocol.
4//!
5//! This library provides a pure Rust implementation for communicating with GPSD,
6//! parsing GPS data, and handling various data stream formats without requiring libgps.
7//!
8//! ## Overview
9//!
10//! GPSD is a service daemon that monitors one or more GPSes or AIS receivers attached
11//! to a host computer through serial or USB ports, making all data on the location/course/velocity
12//! of the sensors available to be queried on TCP port 2947 of the host computer.
13//!
14//! This library implements the JSON-based protocol used by GPSD for client communication,
15//! supporting protocol version 3.x as defined in the GPSD project.
16//!
17//! ## Example
18//!
19//! ```ignore
20//! use gpsd_json::client::{GpsdClient, StreamOptions};
21//! use futures::StreamExt;
22//!
23//! async fn example() -> Result<(), Box<dyn std::error::Error>> {
24//!     // Connect to GPSD server
25//!     let mut client = GpsdClient::connect("127.0.0.1:2947").await?;
26//!
27//!     // Start streaming GPS data in JSON format
28//!     let mut stream = client.stream(StreamOptions::json()).await?;
29//!
30//!     // Process incoming GPS data
31//!     while let Some(result) = stream.next().await {
32//!         println!("Received: {:?}", result?);
33//!     }
34//!     Ok(())
35//! }
36//! ```
37
38use crate::error::GpsdJsonError;
39
40/// Client module for establishing connections and managing communication with GPSD
41pub mod client;
42
43/// Error types used throughout the library
44pub mod error;
45
46/// Protocol definitions and message parsing for GPSD JSON protocol
47pub mod protocol;
48
49/// Convenience type alias for Results with GpsdJsonError
50pub type Result<T> = core::result::Result<T, GpsdJsonError>;