ewilken / hap-rs

Rust implementation of the Apple HomeKit Accessory Protocol (HAP)
Apache License 2.0
196 stars 33 forks source link

make API easier to use with concurrent programs #63

Closed gbaranski closed 2 years ago

gbaranski commented 2 years ago

Hi, I'm trying to implement some code that'd execute on each characteristic update, but unfortunately it's quite complicated to use .on_update(...) right now,

Here's my code:

Screenshot 2021-12-28 at 22 29 02

and unfortunately it won't compile because closure might outlive current function.

is there some approach that you use in this case?

maybe it'd be easier to expose some channels such as mpsc or broadcast from tokio crate?

gbaranski commented 2 years ago

I managed to get it working by adding move keyword before closure.