Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl fmt::Display for GpsdError {
pub fn handshake(
reader: &mut dyn io::BufRead,
writer: &mut dyn io::Write,
) -> Result<(), GpsdError> {
) -> Result<Devices, GpsdError> {
// Get VERSION
let mut data = Vec::new();
reader.read_until(b'\n', &mut data)?;
Expand Down Expand Up @@ -566,14 +566,16 @@ pub fn handshake(
reader.read_until(b'\n', &mut data)?;
trace!("{}", String::from_utf8(data.clone()).unwrap());
let msg: ResponseHandshake = serde_json::from_slice(&data)?;
match msg {
ResponseHandshake::Devices(_) => {}
let devices = match msg {
ResponseHandshake::Devices(devices) => {
devices
}
_ => {
return Err(GpsdError::UnexpectedGpsdReply(
String::from_utf8(data).unwrap(),
))
}
}
};

// Get WATCH
let mut data = Vec::new();
Expand All @@ -599,7 +601,7 @@ pub fn handshake(
}
}

Ok(())
Ok(devices)
}

/// Get one payload entry from `gpsd`.
Expand Down