[GH-ISSUE #16] Hey, wonder if you're interested in Stream API #7

Closed
opened 2026-05-22 22:04:47 +01:00 by JakeStanger · 3 comments
Owner

Originally created by @ogios on GitHub (Feb 5, 2025).
Original GitHub issue: https://github.com/JakeStanger/system-tray/issues/16

Really enjoy system-tray, big thanks to you.

Recently i've been working on a Stream API which is able to run this without tokio.
it performs like this:

    let client = Client::new().await.unwrap();
    let mut stream = client.create_stream().await.unwrap();

    while let Some(event) = stream.next().await {
        println!("{event:?}");
    }

and we can do this for zbus:

# Cargo.toml

[features]
default = ["tokio"]
unstable_stream = ["zbus/async-io", "dep:futures"]
tokio = ["zbus/tokio", "dep:tokio"]

[dependencies]
zbus = { version = "5.3", default-features = false, optional = true }
tokio = { version = "1", features = ["rt", "sync", "macros", "time"], optional = true }
futures = { version = "0.3.31", optional = true }
tracing = "0.1.41"
serde = { version = "1", features = ["derive"] }
thiserror = "2.0.11"

it is almost done https://github.com/ogios/system-tray-zbus5/pull/10, but of course it is the first time i write async rust code like this, so it's tagged unstable.

i can port it here if you are interested.

Originally created by @ogios on GitHub (Feb 5, 2025). Original GitHub issue: https://github.com/JakeStanger/system-tray/issues/16 Really enjoy `system-tray`, big thanks to you. Recently i've been working on a `Stream` API which is able to run this without tokio. it performs like this: ```rust let client = Client::new().await.unwrap(); let mut stream = client.create_stream().await.unwrap(); while let Some(event) = stream.next().await { println!("{event:?}"); } ``` and we can do this for zbus: ```toml # Cargo.toml [features] default = ["tokio"] unstable_stream = ["zbus/async-io", "dep:futures"] tokio = ["zbus/tokio", "dep:tokio"] [dependencies] zbus = { version = "5.3", default-features = false, optional = true } tokio = { version = "1", features = ["rt", "sync", "macros", "time"], optional = true } futures = { version = "0.3.31", optional = true } tracing = "0.1.41" serde = { version = "1", features = ["derive"] } thiserror = "2.0.11" ``` it is almost done https://github.com/ogios/system-tray-zbus5/pull/10, but of course it is the first time i write async rust code like this, so it's tagged `unstable`. i can port it here if you are interested.
Author
Owner

@JakeStanger commented on GitHub (Feb 5, 2025):

Hey, I agree it would be good to be able to support async runtimes other than Tokio. I'm not seeing why all of this work is necessary though, so might need some explanation. zbus is runtime-agnostic and we can just offer a feature flag to turn its special Tokio support on/off.

What does the Stream API do here do that I'm missing?

<!-- gh-comment-id:2637109497 --> @JakeStanger commented on GitHub (Feb 5, 2025): Hey, I agree it would be good to be able to support async runtimes other than Tokio. I'm not seeing why all of this work is necessary though, so might need some explanation. `zbus` is runtime-agnostic and we can just offer a feature flag to turn its special Tokio support on/off. What does the `Stream` API do here do that I'm missing?
Author
Owner

@ogios commented on GitHub (Feb 5, 2025):

yes for zbus we can provide a feature flag, but this crate still needs tokio as a dependency when using the Client.

the stream api i'm working on is not bounded to tokio which means the user can choose to remove the tokio dependency

<!-- gh-comment-id:2637207487 --> @ogios commented on GitHub (Feb 5, 2025): yes for zbus we can provide a feature flag, but this crate still needs tokio as a dependency when using the Client. the stream api i'm working on is not bounded to tokio which means the user can choose to remove the tokio dependency
Author
Owner

@JakeStanger commented on GitHub (Feb 12, 2025):

I see. In that case yes I think it would be a good thing to have.

From a look at your branch, it seems to duplicate a lot of the code. I'd want to minimise that before merging in.

<!-- gh-comment-id:2654578687 --> @JakeStanger commented on GitHub (Feb 12, 2025): I see. In that case yes I think it would be a good thing to have. From a look at your branch, it seems to duplicate a lot of the code. I'd want to minimise that before merging in.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/system-tray#7
No description provided.