# BINEX
[](https://github.com/georust/rinex/actions/workflows/rust.yml)
[](https://github.com/georust/rinex/actions/workflows/daily.yml) [](https://crates.io/crates/binex) [](https://docs.rs/binex/badge.svg)
BINEX is a simple library to decode and encode BINEX messages.
BINEX stands for BINary EXchange and is the "real time" stream oriented
version of the RINEX format. It is to this day, the only open source protocol
to encode GNSS and navigation data.
While RINEX is readable and based on line termination, BINEX is real-time and
hardware orientated (at the GNSS receiver firmware level).
This library allows easy message encoding and decoding, and aims at providing seamless
convertion from RINEX back and forth.
You have two scenarios to approach a BINEX stream:
* use our Decoder object, which works on I/O interface directly
and can represent a stream of continuous of either Messages (open source)
or undisclosed elements. (private prototypes)
* or use Message::decode to work on your own buffer directly.
Message Decoding
================
Use the BINEX `Decoder` to decode a `Readable` interface streaming
BINEX messages. Decoder exposes both open source Messages that
were fully interprated and closed source Messages (undisclosed prototypes)
that it cannot interprate:
```rust
use std::fs::File;
use binex::prelude::{Decoder, StreamElement, Provider, Error};
let fd = File::open("../test_resources/BIN/mfle20190130.bnx")
.unwrap();
let mut decoder = Decoder::new(fd);
loop {
match decoder.next() {
Some(Ok(StreamElement::OpenSource(msg))) => {
// fully interprated element
},
Some(Ok(StreamElement::ClosedSource(element))) => {
// verify this is your organization
if element.meta.provider == Provider::JPL {
// grab fields that you probably need to decode
let mid = element.meta.mid;
let mlen = element.meta.mlen;
let big_endian = element.meta.big_endian;
let is_reversed = element.meta.reversed;
let enhanced_crc = element.meta.enhanced_crc;
// now, proceed to interpretation of this element,
// using undisclosed method
element.interprate(&|data| {
match mid {
_ => {},
}
});
}
},
Some(Err(e)) => {
// it is possible that some frames may not
// be supported yet.
// Any I/O error should not happen.
},
None => {
// end of stream
break;
},
}
}
```
Message Forging
===============
The BINEX library allows easy message forging. Each message can be easily encoded and then
streamed into a `Writable` interface:
```rust
```
## Licensing
Licensed under either of:
* Apache Version 2.0 ([LICENSE-APACHE](http://www.apache.org/licenses/LICENSE-2.0))
* MIT ([LICENSE-MIT](http://opensource.org/licenses/MIT)