Skip to content

Commit 1ed4d5e

Browse files
authored
Merge pull request #78 from collabora/updates
Various updates
2 parents d3538cc + e3aad32 commit 1ed4d5e

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,42 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: actions-rs/toolchain@v1
18+
- uses: dtolnay/rust-toolchain@master # avoid the tag here to prevent dependabot from updating it
1919
with:
20-
toolchain: stable
21-
- uses: actions-rs/cargo@v1
22-
with:
23-
command: check
24-
args: --all-features
25-
20+
toolchain: "1.70"
21+
- run: cargo check --all-targets --all-features
2622
fmt:
2723
name: cargo fmt
2824
runs-on: ubuntu-latest
2925
steps:
3026
- uses: actions/checkout@v4
31-
- uses: actions-rs/toolchain@v1
32-
with:
33-
toolchain: stable
34-
- uses: actions-rs/cargo@v1
27+
- uses: dtolnay/rust-toolchain@master # avoid the tag here to prevent dependabot from updating it
3528
with:
36-
command: fmt
37-
args: --all --check
38-
29+
toolchain: "1.70"
30+
components: rustfmt
31+
- run: cargo fmt --all --check
3932
test:
4033
name: cargo test
4134
runs-on: ubuntu-latest
4235
steps:
4336
- uses: actions/checkout@v4
4437
with:
4538
lfs: 'true'
46-
- uses: actions-rs/toolchain@v1
47-
with:
48-
toolchain: stable
49-
- uses: actions-rs/cargo@v1
39+
- uses: dtolnay/rust-toolchain@master # avoid the tag here to prevent dependabot from updating it
5040
with:
51-
command: test
41+
toolchain: "1.70"
42+
- run: cargo test --all-targets --all-features
5243

5344
clippy:
5445
name: cargo clippy
5546
runs-on: ubuntu-latest
5647
steps:
5748
- uses: actions/checkout@v4
58-
- uses: actions-rs/toolchain@v1
59-
with:
60-
toolchain: stable
61-
- uses: actions-rs/cargo@v1
49+
- uses: dtolnay/rust-toolchain@master # avoid the tag here to prevent dependabot from updating it
6250
with:
63-
command: clippy
64-
args: -- -D warnings
51+
toolchain: "1.70"
52+
components: clippy
53+
- run: cargo clippy --all-targets --all-features -- -D warnings
6554

6655
# Job to key success status against
6756
allgreen:

bmap-parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bmap-parser"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Sjoerd Simons <sjoerd@collabora.com>"]
55
edition = "2018"
66
license = "MIT AND Apache-2.0"

bmap-parser/src/bmap.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,42 @@ impl Bmap {
6565
BmapBuilder::default()
6666
}
6767

68+
/// Build from a .bmap xml file
6869
pub fn from_xml(xml: &str) -> Result<Self, xml::XmlError> {
6970
xml::from_xml(xml)
7071
}
7172

73+
/// Image size in bytes
7274
pub fn image_size(&self) -> u64 {
7375
self.image_size
7476
}
7577

78+
/// block size in bytes
7679
pub const fn block_size(&self) -> u64 {
7780
self.block_size
7881
}
7982

83+
/// number of blocks in the image
8084
pub fn blocks(&self) -> u64 {
8185
self.blocks
8286
}
8387

88+
/// number of mapped blocks in the image
8489
pub fn mapped_blocks(&self) -> u64 {
8590
self.mapped_blocks
8691
}
8792

93+
/// checksum type used
8894
pub fn checksum_type(&self) -> HashType {
8995
self.checksum_type
9096
}
9197

98+
/// Iterator over the block map
9299
pub fn block_map(&self) -> impl ExactSizeIterator + Iterator<Item = &BlockRange> {
93100
self.blockmap.iter()
94101
}
102+
103+
/// Total mapped size in bytes
95104
pub fn total_mapped_size(&self) -> u64 {
96105
self.block_size * self.mapped_blocks
97106
}

bmap-parser/src/discarder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ impl<R: AsyncRead + Unpin> AsyncRead for AsyncDiscarder<R> {
6464
}
6565
}
6666

67-
#[async_trait(?Send)]
68-
impl<R: AsyncRead + Unpin> AsyncSeekForward for AsyncDiscarder<R> {
67+
#[async_trait]
68+
impl<R: AsyncRead + Unpin + Send> AsyncSeekForward for AsyncDiscarder<R> {
6969
async fn async_seek_forward(&mut self, forward: u64) -> IOResult<()> {
7070
let mut buf = [0; 4096];
7171
let mut left = forward as usize;
@@ -95,7 +95,7 @@ mod test {
9595
.iter()
9696
.fold(0, |pos, offset| {
9797
let mut byte: u8 = 1;
98-
discarder.seek_forward((offset - pos) as u64).unwrap();
98+
discarder.seek_forward(offset - pos).unwrap();
9999
assert_eq!(1, discarder.read(slice::from_mut(&mut byte)).unwrap());
100100
assert_eq!(*offset, byte as u64);
101101
*offset + 1

bmap-parser/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ impl<T: Seek> SeekForward for T {
2323
}
2424
}
2525

26-
#[async_trait(?Send)]
26+
#[async_trait]
2727
pub trait AsyncSeekForward {
2828
async fn async_seek_forward(&mut self, offset: u64) -> IOResult<()>;
2929
}
3030

31-
#[async_trait(?Send)]
31+
#[async_trait]
3232
impl<T: AsyncSeek + Unpin + Send> AsyncSeekForward for T {
3333
async fn async_seek_forward(&mut self, forward: u64) -> IOResult<()> {
3434
self.seek(SeekFrom::Current(forward as i64)).await?;

bmap-parser/tests/copy.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,16 @@ fn setup_data(basename: &str) -> (Bmap, impl Read + SeekForward) {
118118
let mut bmapfile = datadir.clone();
119119
bmapfile.push(format!("{}.bmap", basename));
120120

121-
let mut b = File::open(&bmapfile).expect(&format!("Failed to open bmap file:{:?}", bmapfile));
121+
let mut b =
122+
File::open(&bmapfile).unwrap_or_else(|_| panic!("Failed to open bmap file:{:?}", bmapfile));
122123
let mut xml = String::new();
123124
b.read_to_string(&mut xml).unwrap();
124125
let bmap = Bmap::from_xml(&xml).unwrap();
125126

126127
let mut datafile = datadir.clone();
127128
datafile.push(format!("{}.gz", basename));
128-
let g = File::open(&datafile).expect(&format!("Failed to open data file:{:?}", datafile));
129+
let g =
130+
File::open(&datafile).unwrap_or_else(|_| panic!("Failed to open data file:{:?}", datafile));
129131
let gz = GzDecoder::new(g);
130132
let gz = Discarder::new(gz);
131133

bmap-rs/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bmap-rs"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Sjoerd Simons <sjoerd@collabora.com>"]
55
edition = "2018"
66
license = "MIT AND Apache-2.0"
@@ -11,11 +11,11 @@ readme = "../README.md"
1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

1313
[dependencies]
14-
bmap-parser = { path = "../bmap-parser", version = "0.1.0"}
14+
bmap-parser = { path = "../bmap-parser", version = "0.2.0"}
1515
anyhow = "1.0.66"
1616
nix = { version = "0.27.1", features = ["fs"] }
1717
flate2 = "1.0.24"
18-
clap = { version = "4.0.18", features = ["cargo"] }
18+
clap = { version = "~4.4.0", features = ["cargo"] }
1919
indicatif = { version = "0.17.1", features = ["tokio"] }
2020
async-compression = { version = "0.4.5", features = ["gzip", "futures-io"] }
2121
tokio = { version = "1.21.2", features = ["rt", "macros", "fs", "rt-multi-thread"] }

0 commit comments

Comments
 (0)