pub trait GpsdJsonDecode: BufRead {
// Provided method
fn read_response<Response>(
&mut self,
buf: &mut Vec<u8>,
) -> Result<Option<Response>>
where Response: GpsdJsonResponse { ... }
}Expand description
Extension trait for reading GPSD JSON responses from a buffered reader
This trait provides functionality to read and parse GPSD JSON messages
from any type that implements BufRead. Messages are expected to be
newline-delimited JSON objects.
Provided Methods§
Sourcefn read_response<Response>(
&mut self,
buf: &mut Vec<u8>,
) -> Result<Option<Response>>where
Response: GpsdJsonResponse,
fn read_response<Response>(
&mut self,
buf: &mut Vec<u8>,
) -> Result<Option<Response>>where
Response: GpsdJsonResponse,
Reads and deserializes a single GPSD response message
§Arguments
buf- A reusable string buffer for reading data
§Returns
Ok(Some(response))- Successfully parsed response messageOk(None)- End of stream reachedErr(_)- I/O or parsing error occurred
§Example
let mut buf = Vec::new();
if let Ok(Some(response)) = reader.read_response::<ResponseMessage>(&mut buf) {
// Process the response
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.