-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
gio: add FileEnumerator::into_stream #1035
Conversation
4ca6fa1
to
27a015e
Compare
} | ||
|
||
impl futures_core::Stream for FileEnumeratorStream { | ||
type Item = Result<Vec<FileInfo>, glib::Error>; |
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.
Why not a glib::List<FileInfo>
?
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.
tbh, I'd leave glib::List
to API that interface directly with C. This is a Rust convenience, so I'd recommend using native/idiomatic Rust type wherever possible.
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.
glib::List
works as an Iterator
so that for the majority of uses it should be equivalent except for not having to copy over everything into 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.
This is just passing the vec from the underlying next_files_future
, it is already converted by the time the stream gets it. It should probably be changed in gir to use List
, and then it can be changed here
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.
See gtk-rs/gir#1447
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.
Looks good to me otherwise. I wonder if there are more APIs like this
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.
Maybe this could be implemented with https://docs.rs/futures-util/latest/futures_util/stream/struct.IntoStream.html?
But then we can't specify the needed arguments, like the number of files... Feel free to ignore this comment.
That is only for a single element stream unfortunately, no first-class support for it like |
cc @ebassi