Skip to content

Commit

Permalink
Accept empty latching field in connection headers (#5)
Browse files Browse the repository at this point in the history
The code will accept such files, but will raise a warning.

This PR also update dependencies, bumps MSRV to 1.63,
 and fixes two Clippy warnings.

Closes #4
  • Loading branch information
newpavlov authored May 22, 2024
1 parent 1a3aa5a commit fdd2774
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rosbag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0 # MSRV
toolchain: 1.63.0 # MSRV
components: clippy
override: true
profile: minimal
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- 1.63.0 # MSRV
- stable
steps:
- uses: actions/checkout@v1
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.6.2 - 2024-05-22
### Changed
- Accept empty `latching` field in connection headers ([#5])

[#5]: https://github.com/newpavlov/rosbag-rs/pull/5


## 0.6.1 - 2022-09-02
### Changed
- The crate has migrated to a new repository ([#1])
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "rosbag"
version = "0.6.1"
version = "0.6.2"
description = "Utilities for reading ROS bag files."
authors = ["Artyom Pavlov <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.56"
rust-version = "1.63"
readme = "README.md"
documentation = "https://docs.rs/rosbag"
repository = "https://github.com/newpavlov/rosbag-rs"
Expand All @@ -15,7 +15,7 @@ categories = ["parser-implementations", "science::robotics"]
[dependencies]
byteorder = "1.1"
bzip2 = "0.4.3"
base16ct = "0.1"
base16ct = "0.2"
log = "0.4.4"
lz4 = "1.23.2"
memmap2 = "0.5"
memmap2 = "0.9"
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ for record in bag.index_records() {
}
```

## Minimum Supported Rust Version

Rust **1.56** or higher.

Minimum supported Rust version can be changed in the future, but it will be
done with a minor version bump.

## License

The crate is licensed under either of
Expand Down
7 changes: 3 additions & 4 deletions src/record_types/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ pub enum Compression {

impl Compression {
fn decompress(self, data: &[u8], decompressed_size: Option<u32>) -> Result<Cow<'_, [u8]>> {
let decompressed_len = decompressed_size.map(|s| s as usize).unwrap_or(data.len());
Ok(match self {
Compression::Bzip2 => {
let mut decompressed = Vec::new();
decompressed.reserve(decompressed_size.map(|s| s as usize).unwrap_or(data.len()));
let mut decompressed = Vec::with_capacity(decompressed_len);
let mut decompressor = bzip2::Decompress::new(false);
decompressor
.decompress_vec(data, &mut decompressed)
Expand All @@ -32,8 +32,7 @@ impl Compression {
Compression::Lz4 => {
let mut decoder = lz4::Decoder::new(data)
.map_err(|e| Error::Lz4DecompressionError(e.to_string()))?;
let mut decompressed = Vec::new();
decompressed.reserve(decompressed_size.map(|s| s as usize).unwrap_or(data.len()));
let mut decompressed = Vec::with_capacity(decompressed_len);
std::io::copy(&mut decoder, &mut decompressed).map_err(|_| {
Error::Lz4DecompressionError("Error while decoding".to_string())
})?;
Expand Down
4 changes: 4 additions & 0 deletions src/record_types/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ impl<'a> RecordGen<'a> for Connection<'a> {
latching = match val {
b"1" => true,
b"0" => false,
b"" => {
log::warn!("Got empty latching field, interpreting it as 0");
false
}
_ => return Err(Error::InvalidRecord),
}
}
Expand Down

0 comments on commit fdd2774

Please sign in to comment.