Skip to content

Commit

Permalink
Builder for sections 1 & 3 (#8)
Browse files Browse the repository at this point in the history
* Section3 builder

* Dependency on derive_builder

* Split Error in a module

* Moving Section1 to a module by itself

* Temporary fix

* Test everything

* Cleanning

Don't need it in the core library but only in the module.

* Some general info, but still incomplete

* Patch upgrade

Skeleton for a builder.
  • Loading branch information
castelao committed Jun 4, 2023
1 parent b9111e7 commit 382f496
Show file tree
Hide file tree
Showing 7 changed files with 467 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
args: --no-fail-fast --workspace

coverage:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[workspace]
members = [ "bufr-lib", "bufr-dump"]

[workspace.package]
version = "0.1.3"

default-members = [ "bufr-lib" ]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,24 @@

A BUFR parser for humans. Sometimes we just want to check one certain metadata
of a file.

## Minimum supported Rust version

Currently the minimum supported Rust version is 1.69.0

## License

Licensed under either of

* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.

## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
3 changes: 2 additions & 1 deletion bufr-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bufr"
version = "0.1.2"
version.workspace = true
authors = ["Luiz Irber <luiz.irber@gmail.com>", "Guilherme Castelão <guilherme@castelao.net>"]
edition = "2018"
description = "BUFR is binary data format defined by WMO focused on real-time data."
Expand All @@ -13,6 +13,7 @@ repository = "https://github.com/castelao/BUFR"
[dependencies]
bitreader="0.3"
csv="1.1"
derive_builder = "0.12.0"
thiserror = "1.0"
getset = "0.1.1"
serde = { version = "1.0.125", features = ["derive"] }
Expand Down
40 changes: 40 additions & 0 deletions bufr-lib/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//#![deny(missing_docs)]

/// Possible errors when parsing BUFR messages
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Message too short to even contain the total size
#[error("BUFR message is too short, less than 8 bytes")]
MessageTooShort,

/// Wrong magic number
#[error("BUFR message should start with BUFR")]
MagicNumber,

/// Wrong end section
#[error("BUFR message should end with 7777")]
EndSection,

/// Message shorter than specified on section 0
#[error("Message shorter than expected, is it truncated?")]
TruncatedMessage,

/// BUFR version not supported
#[error("BUFR version {0} not supported")]
VersionNotSupported(u8),

/*
/// Number of descriptors doesn't match the size
#[error("Expected {n_descriptors} descriptors, requiring {descriptor_size}B but buffer size {buffer_size}B")]
WrongNumberOfDescriptors {
n_descriptors: u16,
descriptor_size: usize,
buffer_size: usize,
},
*/
#[error("Section 3 must be larger than 7 and an odd number, got {0}")]
InvalidSection3Length(usize),

#[error(transparent)]
IOError(#[from] std::io::Error),
}
Loading

0 comments on commit 382f496

Please sign in to comment.