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