Skip to content

Replace archived core2 dependency with no_std_io2#185

Merged
vmx merged 2 commits intomultiformats:masterfrom
BentenAI:replace-core2-with-no-std-io2
Apr 15, 2026
Merged

Replace archived core2 dependency with no_std_io2#185
vmx merged 2 commits intomultiformats:masterfrom
BentenAI:replace-core2-with-no-std-io2

Conversation

@Benten-Ben
Copy link
Copy Markdown
Contributor

Summary

core2 was archived upstream on 2026-04-14 with the note "No longer supported. Use core directly." Version 0.4.0 is yanked from crates.io with no replacement, making cid currently unbuildable from a clean checkout against the default registry.

This PR swaps core2 for no_std_io2, an API-compatible drop-in replacement purpose-built for crates that need std::io's trait shape in no_std contexts.

Approach

Mirrors the approach in multiformats/rust-multihash#407 for multiformats org consistency. The diff is the minimum needed:

  • Cargo.toml: replace the core2 dependency with no_std_io2 = "0.8.1"; update two feature flags (std, alloc) to reference no_std_io2/alloc instead of core2/alloc.
  • src/cid.rs, src/error.rs: replace the two use core2::io; imports with use no_std_io2::io;.

No other changes. no_std_io2's io::Read and io::Error types preserve the exact surface previously consumed from core2::io.

Alternatives considered

  • core::io::{Read, Write}: not stable (rust-lang/rust#68315 has been open since 2020, blocked on the std::io::Error OS-coupling problem).
  • embedded-io: more idiomatic for new work, but introduces a different trait surface and would be a larger, more opinionated change. Happy to rework as embedded-io if maintainers prefer.
  • Vendored internal shim: minimal diff but leaves the org inconsistent with the rust-multihash migration.

Testing

Currently, cid's own dev-dependency chain (multihash-codetable) pulls core2 transitively, so the upstream test suite can't build against a clean registry until #407 merges and a release is cut. Once that lands, the test suite unblocks automatically.

The library itself compiles cleanly against no_std_io2 for --all-features, --no-default-features, and --no-default-features --features alloc.

Refs

Closes #184.

core2 was archived upstream on 2026-04-14 ("No longer supported. Use
core directly."). core::io::{Read, Write} are not yet stable in Rust
(tracking issue rust-lang/rust#68315), so a direct migration is not
currently possible.

no_std_io2 0.8.1 is an API-compatible drop-in replacement for core2's
io module, purpose-built for crates that need the std::io trait shape
in no_std contexts.

This mirrors the approach taken in multiformats/rust-multihash#407
for multiformats org consistency.

Closes multiformats#184.
@Benten-Ben
Copy link
Copy Markdown
Contributor Author

Note on CI: all 7 checks are failing with error: failed to select a version for the requirement 'core2 = "^0.4.0"' (version 0.4.0 is yanked), which is the pre-existing breakage on master that issue #184 tracks and that this PR begins resolving. The remaining chain is multihash-codetable -> core2, which #407 addresses. Once #407 merges and the multihash crates are released, rust-cid's test suite should go green on this PR (plus possibly a matching dev-dep version bump to multihash-codetable = "0.2").

@hanabi1224
Copy link
Copy Markdown
Contributor

hanabi1224 commented Apr 15, 2026

Could we make no_std_io2 optional and only opt-in when no_std feature is enabled? That is to say,

  • when std is enabled, use std traits
  • when no_std is enabled, use no_std_io2 traits
  • when neither is enabled, skip implementing Write

@LesnyRumcajs
Copy link
Copy Markdown

Could we make no_std_io2 optional and only opt-in when no_std feature is enabled?

That'd be a great improvement, I don't think there's a point in pulling this dependency for every project, especially given that I'd imagine most projects using this crate aren't restricted by no_std.

@vmx
Copy link
Copy Markdown
Member

vmx commented Apr 15, 2026

Thanks @Benten-Ben for the PR. Could you please add a comment to #177. I still hope that license change eventually happens.

@vmx
Copy link
Copy Markdown
Member

vmx commented Apr 15, 2026

Could we make no_std_io2 optional and only opt-in when no_std feature is enabled? That is to say,

@hanabi1224 That sounds good to me. But I first want to get this patch release with minimal changes out quickly. PRs are welcome to improve things in regards to std/no_std.

@vmx vmx merged commit 54855ba into multiformats:master Apr 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dependency core2@0.4.0 yanked

5 participants