Skip to content

Embed minimal required no_std_io2 traits#411

Open
hanabi1224 wants to merge 3 commits intomultiformats:masterfrom
hanabi1224:embed-nostd-io
Open

Embed minimal required no_std_io2 traits#411
hanabi1224 wants to merge 3 commits intomultiformats:masterfrom
hanabi1224:embed-nostd-io

Conversation

@hanabi1224
Copy link
Copy Markdown
Contributor

@hanabi1224 hanabi1224 commented Apr 16, 2026

This PR embedded minimal no_std_io2 traits that are required by multihash. It should require a minor version bump

@hanabi1224 hanabi1224 marked this pull request as ready for review April 16, 2026 01:24
@vmx
Copy link
Copy Markdown
Member

vmx commented Apr 17, 2026

As it's not as urgent as getting a quick fix out, other things came in between. I'll review it next week.

As the no-std `Error` is a trimmed down version specifically for this
library, it can be simplified.

Also add some doc comments back in.
Copy link
Copy Markdown
Member

@vmx vmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a new commit, as it was easier to do it that way than leaving a comment. A review from you on my changes would be great.

Though I've one comment left, where I don't understand why you made it std only.

($name:ident) => {
impl<const S: usize> no_std_io2::io::Write for $name<S> {
fn write(&mut self, buf: &[u8]) -> no_std_io2::io::Result<usize> {
#[cfg(feature = "std")]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to just add something like this at the top:

#[cfg(feature = "std")]
use std::io;

#[cfg(not(feature = "std"))]
use crate::no_std_io as io;

Copy link
Copy Markdown
Contributor Author

@hanabi1224 hanabi1224 Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.
(Did not implement the custom Write trait to not allow downstream crates to depend on it. But that might not be an issue.)
(Top-level use may not work when the macro is used in another file, using the full trait name instead)

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.

2 participants