Created
May 9, 2020 19:41
-
-
Save silverjam/4b01b8e208321da2895ca9361abb163e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "sbptest" | |
version = "0.1.0" | |
authors = ["Jason Mobarak <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
sbp = { git = "https://github.com/swift-nav/libsbp", branch = "master" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::boxed::Box; | |
use std::error::Error; | |
use std::fs::File; | |
use std::io::BufReader; | |
use std::io::ErrorKind; | |
use std::result::Result; | |
use sbp::messages::SBP; | |
use sbp::Error as SbpError; | |
fn main() -> Result<(), Box<dyn Error>> { | |
let file = File::open("input.sbp",)?; | |
let mut reader = BufReader::new(file); | |
let mut parser = sbp::parser::Parser::new(); | |
loop { | |
match parser.parse(&mut reader) { | |
Ok(SBP::MsgLog(x)) => println!("{}", x.text), | |
Ok(_) => (), | |
Err(SbpError::IoError(err)) => { | |
if err.kind() != ErrorKind::UnexpectedEof { | |
println!("Got an IO error: {:?}", err); | |
} | |
break; | |
} | |
Err(err) => { | |
println!("Got an unexpected error: {:?}", err); | |
break; | |
} | |
} | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment