-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Implement safe io #871
base: master
Are you sure you want to change the base?
Implement safe io #871
Conversation
1200fdd
to
281adac
Compare
Added commit descriptions where there were api questions. |
2b2aeee
to
b8c5eb6
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me otherwise
16e67be
to
86cfed9
Compare
Rebased. There were quite many conflicts so a review would be appreciated. |
Is this ready for another review and potentially merging? |
Yes and maybe |
gio/src/unix_fd_list.rs
Outdated
unsafe { | ||
let mut length = mem::MaybeUninit::uninit(); | ||
let ret = FromGlibContainer::from_glib_full_num( | ||
let ret: Vec<RawFd> = FromGlibContainer::from_glib_full_num( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least this one here should be a glib::Slice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but the return type is still Vec<BorrowedFd<'_>>
, which is kinda odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says steal
here so they're probably not borrowed but owned?
Also why don't you use glib::Slice
here to avoid the copy to a Vec
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to do the map RawFd->BorrowedFd without ownership issues at the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OwnedFd
has the same layout as an actual fd so you could just cast things.
I think the correct thing to do here (because glib::Slice
requires all the traits for the contained type) is to define a new struct FdArray(...)
that stores a glib::Slice<i32>
and can Deref
into BorrowedFd
and IntoIterator<Item = OwnedFd>
, and on Drop
frees things accordingly.
rebased. I don't quite remember the state of this. It should be fine, iirc. |
5135cd7
to
4b9a92b
Compare
I removed the extra functions, since yeah in all cases you can unsafely use them with BorrowedFd::borrow_raw and OwnedFd::form_raw_fd. |
For the from_owned_fd it might make sense to implement From or replace the unsafe from_fd/take_fd methods.
Needs reviewing
Stuff thats missing