Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce RestrictAccess<To> and generalize restrict to all access types #60

Merged
merged 11 commits into from
Apr 26, 2024

Conversation

mkroening
Copy link
Member

This PR introduces trait RestrictAccess<T> to generalize the restriction from any access type to any other access type, to implement Volatile{Ptr,Ref}::restrict generically for all access types.

While not required, this PR also replaces and deprecates Access::RestrictShared, since it is equivalent to RestrictAccess<ReadOnly>::Restricted.

Though also optional, I implemented Readable, Writable, and Copyable in terms of RestrictAccess.

This PR depends on #59.

@mkroening mkroening marked this pull request as ready for review April 25, 2024 16:25
Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

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

Nice abstraction! It makes things a bit more complex, but also more flexible.

I think it would be a good idea to do the breaking release quickly and remove the associated RestrictShared type. Otherwise I fear that the two ways to restrict access could lead to confusion. What do you think?

Ready for merge from my side after a rebase.

src/access.rs Outdated Show resolved Hide resolved
@mkroening
Copy link
Member Author

I think it would be a good idea to do the breaking release quickly and remove the associated RestrictShared type. Otherwise I fear that the two ways to restrict access could lead to confusion. What do you think?

Works for me. I rebased, removed RestrictShared and added a commit for making the bounds on the Readable, Writable, and Copyable traits consistent.

Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

@phil-opp phil-opp merged commit 53c30e7 into rust-osdev:main Apr 26, 2024
5 of 6 checks passed
@mkroening mkroening deleted the general-restrict branch April 26, 2024 09:33
@phil-opp phil-opp mentioned this pull request Jun 6, 2024
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.

None yet

2 participants