binex/lib.rs
1#![doc(html_logo_url = "https://raw.githubusercontent.com/rtk-rs/.github/master/logos/logo2.jpg")]
2#![doc = include_str!("../README.md")]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4
5use thiserror::Error;
6
7mod decoder;
8mod message;
9mod stream;
10
11pub(crate) mod utils;
12
13pub mod prelude {
14 pub use crate::{
15 decoder::Decoder,
16 message::{
17 EphemerisFrame, GALEphemeris, GLOEphemeris, GPSEphemeris, GPSRaw, GeoStringFrame,
18 Message, Meta, MonumentGeoMetadata, MonumentGeoRecord, PositionEcef3d, PositionGeo3d,
19 Record, SBASEphemeris, Solutions, SolutionsFrame, TemporalSolution, Velocity3d,
20 VelocityNED3d,
21 },
22 stream::{ClosedSourceElement, Provider, StreamElement},
23 ClosedSourceMeta, Error,
24 };
25 // re-export
26 pub use hifitime::{Epoch, TimeScale};
27}
28
29use crate::message::Meta;
30use crate::stream::Provider;
31
32/// [ClosedSourceMeta] helps identify a closed source message we cannot interprate.
33#[derive(Debug, Copy, Clone)]
34pub struct ClosedSourceMeta {
35 /// Message ID "as is"
36 pub mid: u32,
37 /// Message length (total payload) "as is"
38 pub mlen: usize,
39 /// Size of chunk.
40 /// This library is designed to support all open source messages that are short.
41 /// Yet a BINEX (prototype) message may span 2^27 bytes.
42 pub size: usize,
43 /// [Meta] data that follows the open source protocol.
44 pub open_meta: Meta,
45 /// [Provider] of this message. Only this organization may fully decode this message.
46 pub provider: Provider,
47 // payload offset in buffer
48 offset: usize,
49}
50
51#[derive(Debug)]
52pub enum Error {
53 /// Not enough bytes available to continue decoding process
54 NotEnoughBytes,
55 /// I/O error
56 IoError,
57 /// Missing SYNC byte
58 NoSyncByte,
59 // InvalidStartofStream,
60 /// Library limitation: reversed streams are not supported
61 ReversedStream,
62 /// Library limitation: enhanced CRC is not supported yet
63 EnhancedCrc,
64 /// Found an unsupported timescale that we cannot interprate.
65 NonSupportedTimescale,
66 /// Found unknown message ID
67 UnknownMessage,
68 /// Error while attempting to interprate UTF-8 (invalid ASCII)
69 Utf8Error,
70 /// Message is missing CRC field and cannot be verified
71 MissingCRC,
72 /// Message corrupt: received CRC does not match expected CRC
73 CorrupctBadCRC,
74 /// Incomplete message: need more data to complete
75 IncompleteMessage(usize),
76 /// Library limitation: not all open source Messages supported yet
77 NonSupportedMesssage(usize),
78 /// Library limtation: not all subrecords supported yet
79 NonSupportedSubRecord,
80 /// Library limtation: should never happen, because this library
81 /// will be designed to parse all open source [Message]s.
82 /// This may happen as either we're still in development (bad internal design)
83 /// or for format that we still do not support (temporarily "ok")
84 TooLargeInternalLimitation,
85 /// Found closed source message
86 ClosedSourceMessage(ClosedSourceMeta),
87}