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

gio: add FileEnumerator::into_stream #1035

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

jf2048
Copy link
Member

@jf2048 jf2048 commented Feb 27, 2023

cc @ebassi

@jf2048 jf2048 requested a review from sdroege February 27, 2023 22:45
}

impl futures_core::Stream for FileEnumeratorStream {
type Item = Result<Vec<FileInfo>, glib::Error>;
Copy link
Member

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>?

Copy link

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.

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@sdroege sdroege left a 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

Copy link
Member

@ranfdev ranfdev left a 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.

@jf2048
Copy link
Member Author

jf2048 commented Feb 28, 2023

That is only for a single element stream unfortunately, no first-class support for it like IntoFuture

@sdroege sdroege merged commit 292f9a3 into gtk-rs:master Feb 28, 2023
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.

4 participants