Skip to content

Commit 8648728

Browse files
authored
fix: remove no_std_io2 from dep tree (#187)
Use the no_std io implementations from the `multihash` crate instead of relying on the external `no_std_io2` dependency.
1 parent 6efdac3 commit 8648728

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ jobs:
5454
run: cargo build --no-default-features --target thumbv6m-none-eabi
5555
shell: bash
5656

57+
build-no-std-with-alloc:
58+
name: Build no_std, but with `alloc` feature enabled
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout Sources
62+
uses: actions/checkout@v6
63+
64+
- name: Install Rust Toolchain
65+
run: rustup target add thumbv6m-none-eabi
66+
shell: bash
67+
68+
- name: Build
69+
# thumbv6m-none-eabi is a platform that doesn't have any std librarry.
70+
# It's often used to make sure that std isn't enabled accidentally.
71+
run: cargo build --no-default-features --features alloc --target thumbv6m-none-eabi
72+
shell: bash
73+
5774
build-no-std-with-serde:
5875
name: Build no_std, but with `serde` feature enabled
5976
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ rust-version = "1.81"
1212

1313
[features]
1414
default = ["std"]
15-
std = ["alloc", "no_std_io2/alloc", "multihash/std", "unsigned-varint/std"]
16-
alloc = ["dep:multibase", "no_std_io2/alloc", "multihash/alloc"]
15+
std = ["alloc", "multihash/std", "unsigned-varint/std"]
16+
alloc = ["dep:multibase", "multihash/alloc"]
1717
arb = ["dep:arbitrary", "dep:quickcheck", "dep:rand", "multihash/arb"]
1818
scale-codec = ["dep:parity-scale-codec", "multihash/scale-codec"]
1919
serde-codec = ["serde"] # Deprecated, don't use.
2020
serde = ["alloc", "dep:serde", "dep:serde_bytes", "multihash/serde"]
2121

2222
[dependencies]
23-
multihash = { version = "0.19.4", default-features = false }
23+
multihash = { version = "0.19.5", default-features = false }
2424
unsigned-varint = { version = "0.8.0", default-features = false }
2525

2626
multibase = { version = "0.9.1", optional = true, default-features = false }
@@ -31,9 +31,7 @@ serde = { version = "1.0.116", default-features = false, optional = true }
3131
serde_bytes = { version = "0.11.5", default-features = false, features = ["alloc"], optional = true }
3232
arbitrary = { version = "1.1.0", optional = true }
3333

34-
no_std_io2 = { version = "0.8.1", default-features = false }
35-
3634
[dev-dependencies]
37-
multihash-derive = { version = "0.9.2", default-features = false }
35+
multihash-derive = { version = "0.9.3", default-features = false }
3836
serde_json = { version = "1.0.59", default-features = false, features = ["alloc"]}
39-
multihash-codetable = { version = "0.2.1", default-features = false, features = ["sha2"] }
37+
multihash-codetable = { version = "0.2.2", default-features = false, features = ["sha2"] }

src/cid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) fn varint_read_u64<R: io::Read>(mut r: R) -> Result<u64> {
5151
use std::io;
5252

5353
#[cfg(not(feature = "std"))]
54-
use no_std_io2::io;
54+
use multihash::no_std_io as io;
5555

5656
use crate::error::{Error, Result};
5757
use crate::version::Version;

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::fmt;
44
use std::io;
55

66
#[cfg(not(feature = "std"))]
7-
use no_std_io2::io;
7+
use multihash::no_std_io as io;
88

99
/// Type alias to use this library's [`Error`] type in a `Result`.
1010
pub type Result<T> = core::result::Result<T, Error>;

0 commit comments

Comments
 (0)