Skip to content

Conversation

@Virv12
Copy link
Contributor

@Virv12 Virv12 commented Nov 30, 2025

A reference to an Event is useless since every api takes an &mut Event, now we return the Event by value.

I also changed the name from wait_for_packet to wait_for_packet_event to match Input::wait_for_key_event and Pointer::wait_for_input_event.

Both of these are breaking changes but it's necessary since it's not usable as it is now.

Copy link
Member

@phip1611 phip1611 left a comment

Choose a reason for hiding this comment

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

LGTM and sensible, thanks! Please keep the name wait_for_packet tho. Further, please add this to the CHANGELOG.md file.

@Virv12
Copy link
Contributor Author

Virv12 commented Dec 1, 2025

Thanks for the review, I updated the PR with the requested changes.

#[must_use]
pub const fn wait_for_packet(&self) -> &Event {
unsafe { &*(ptr::from_ref(&self.0.wait_for_packet).cast::<Event>()) }
pub fn wait_for_packet(&self) -> Option<Event> {
Copy link
Member

Choose a reason for hiding this comment

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

I know you’ve streamlined this with other parts of the code, and that makes sense - thanks for that! However, I'm wondering whether this should instead return Result<Event, SomeError>. When I’m waiting for a packet, I wouldn’t expect this to return None under normal circumstances. Because of that, Id prefer using a Result`.

What do you think, @nicholasbishop ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is not waiting for a packet, it's returning an event that waits for a packet, if the underlying implementation does not support the event, the function might return None.

Copy link
Member

Choose a reason for hiding this comment

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

ah, got it- sorry - thanks!

A reference to an `Event` is useless since every api takes an `&mut Event`, now
we return the `Event` by value.
@phip1611 phip1611 enabled auto-merge December 1, 2025 12:14
@phip1611
Copy link
Member

phip1611 commented Dec 1, 2025

For the record: I've created #1839 as possible follow-up ticket

@phip1611 phip1611 added this pull request to the merge queue Dec 1, 2025
Merged via the queue into rust-osdev:main with commit 585b4dd Dec 1, 2025
16 checks passed
@Virv12 Virv12 deleted the snp branch December 1, 2025 13:01
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