Skip to content

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
@jf2048 jf2048 force-pushed the file-enumerator-stream branch from 4ca6fa1 to 27a015e Compare February 27, 2023 22:51
}

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