Skip to content

Add Cursor type#717

Open
zeenix wants to merge 1 commit intorust-embedded:masterfrom
zeenix:cursor
Open

Add Cursor type#717
zeenix wants to merge 1 commit intorust-embedded:masterfrom
zeenix:cursor

Conversation

@zeenix
Copy link
Copy Markdown

@zeenix zeenix commented Nov 27, 2025

This is a no_std variant of std::io::Cursor.

Fixes #631.

The implementation was generated by an LLM by copying the std impl and adapting it. I (Zeeshan) reviewed the code and adjusted small bits. The tests added are a further assurance that the code is doing what it's supposed to do. Of course, it needs to be still reviewed by at least another person before we can be 100% certain about it.

@zeenix zeenix requested a review from a team as a code owner November 27, 2025 17:42
@zeenix zeenix force-pushed the cursor branch 2 times, most recently from e31ac25 to 35adbdf Compare December 4, 2025 18:41
@zeenix
Copy link
Copy Markdown
Author

zeenix commented Dec 20, 2025

@spookyvision may I ask what makes you 👎 this PR? If it's the use of LLM, perhaps you would have felt fine about this if I hadn't followed the guidelines of the Rust embedded community and hadn't disclosed the use of LLM?

@zeenix zeenix force-pushed the cursor branch 2 times, most recently from e766bae to a61f122 Compare December 30, 2025 17:18
@zeenix
Copy link
Copy Markdown
Author

zeenix commented Dec 30, 2025

I believe I've now addressed all the comments (except for the very unhelpful 👎 reactions from @spookyvision and @jamwaffles, which I can't do anything about).

@Dirbaio Any chance you'd be able to review soon?

MabezDev
MabezDev previously approved these changes Mar 27, 2026
Copy link
Copy Markdown
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

In my opinion this is a solid change, thanks for taking the time to refine the impl.

LGTM, I'll leave the final decision to @Dirbaio as eio is mostly his work.

@zeenix
Copy link
Copy Markdown
Author

zeenix commented Mar 27, 2026

@reitermarkus @MabezDev Thanks so much! I rebased the branch on latest master now.

@zeenix
Copy link
Copy Markdown
Author

zeenix commented Apr 3, 2026

LGTM, I'll leave the final decision to @Dirbaio as eio is mostly his work.

@MabezDev While I think that's fair, I think we also shouldn't block things on @Dirbaio. They have single-handedly created most of this amazing Rust embedded world after all and they are one person in the end. Moreover, I have pinged them many times over the months about this PR, including after your comment on the Matrix channel and here, so it's safe to say that they don't have time for this right now.

So I'd humbly request that this be merged, unless @Dirbaio raises an objection/cocern. It has received multiple reviews and IMO a pretty straight forward PR.

@Dirbaio
Copy link
Copy Markdown
Member

Dirbaio commented Apr 3, 2026

Should this be on embedded-io or on embedded-io-adapters? If it's in embedded-io we can never ever make breaking changes to it once released. (I believe we've already discussed this in Matrix?)

@Dirbaio
Copy link
Copy Markdown
Member

Dirbaio commented Apr 3, 2026

There's some divergence compared to std cursor:

  • impl<const N: usize> Write for Cursor<[u8; N]> is in std but not in e-io.
  • get_mut, set_position are const in std, not in e-io.
  • remaining_slice doesn't exist in std. Do we want to diverge from std here? IMO split() (which is in std) already covers all the use cases of remaining_slice.

@zeenix
Copy link
Copy Markdown
Author

zeenix commented Apr 4, 2026

remaining_slice doesn't exist in std. Do we want to diverge from std here? IMO split() (which is in std) already covers all the use cases of remaining_slice.

remaining_slice did exist in the first iteration but was removed: #717 (comment)


P.S. I'm AFK for a week so I'll address your concerns when I'm back.

@Dirbaio
Copy link
Copy Markdown
Member

Dirbaio commented Apr 4, 2026

remaining_slice did exist in the first iteration but was removed

it wasn't removed, it's still there

@zeenix
Copy link
Copy Markdown
Author

zeenix commented Apr 10, 2026

Should this be on embedded-io or on embedded-io-adapters? If it's in embedded-io we can never ever make breaking changes to it once released. (I believe we've already discussed this in Matrix?)

IMO it belongs here (embedded-io) but I don't foresee any breaking changes in this API. Perhaps that's why it's probably best we discuss this API to death to ensure all is good. :) However, if you or other maintainers think that it's best in the adapters crate, I'm happy to move it.

remaining_slice did exist in the first iteration but was removed

it wasn't removed, it's still there

Ah right. Sorry, I was already on holidays brain. 😆 Since you're the second person to say this here, I guess we can remove it, yeah.

@Dirbaio
Copy link
Copy Markdown
Member

Dirbaio commented Apr 11, 2026

IMO it belongs here (embedded-io) but I don't foresee any breaking changes in this API. Perhaps that's why it's probably best we discuss this API to death to ensure all is good. :) However, if you or other maintainers think that it's best in the adapters crate, I'm happy to move it.

generally we've tried to keep the trait crates as traits only. The adapters could also be in embedded-io but they're in a separate crate due to this.

We can discuss on Tue in the meeting.

@zeenix
Copy link
Copy Markdown
Author

zeenix commented Apr 14, 2026

  • impl<const N: usize> Write for Cursor<[u8; N]> is in std but not in e-io.
  • get_mut, set_position are const in std, not in e-io.
  • remaining_slice doesn't exist in std. Do we want to diverge from std here? IMO split() (which is in std) already covers all the use cases of remaining_slice.

All addressed, I believe.

@zeenix
Copy link
Copy Markdown
Author

zeenix commented Apr 14, 2026

  • get_mut, set_position are const in std, not in e-io.

Oh, turns out there was a reason for this: our MSRV.

This is a no_std variant of `std::io::Cursor`.

Fixes rust-embedded#631.

The implementation was generated by an LLM by copying the std impl and
adapting it. I (Zeeshan) reviewed the code and adjusted small bits. The
tests added are further guarantee that the code is doing what it's
supposed to do.
@zeenix
Copy link
Copy Markdown
Author

zeenix commented Apr 14, 2026

  • get_mut, set_position are const in std, not in e-io.

Oh, turns out there was a reason for this: our MSRV.

I made them non-const again for now. Let me know if you'd rather bump the MSRV and have these const.

I also took the liberty of refactoring a bit to avoid code duplication in all the writing impls.

@Dirbaio
Copy link
Copy Markdown
Member

Dirbaio commented Apr 14, 2026

i'd just bump the MSRV yes

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.

[Feature Request] Provide Cursor Implementation in embedded-io

8 participants