fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.29k stars 301 forks source link

StreamSink impl async fn cancelled() #2339

Open modeckrus opened 1 month ago

modeckrus commented 1 month ago

I use spawn to send something in stream via StreamSink, and I want to close this green thread when dart stream is closed. So I suggest to add method for StreamSink cancelled like in https://docs.rs/tokio-util/latest/tokio_util/sync/struct.CancellationToken.html

welcome[bot] commented 1 month ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 1 month ago

Looks reasonable and feel free to PR for this new feature! Alternatively I may work on it later.

As a workaround before it is implemented, you can explicitly call a Rust function marking it is closed when that happens.