-
Notifications
You must be signed in to change notification settings - Fork 44
Power policy direct async call #553
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
base: v0.2.0
Are you sure you want to change the base?
Changes from all commits
1e61cdf
593f061
46cdef5
34701dd
8f15e47
bddad8a
81de3e8
dedc4b8
a10cc63
41b14c1
5d4ba5c
da31fca
38fb44b
b3cc2f6
0a0c80f
1a7477d
daa1cc7
2fa1e17
9448315
fd95083
7f52bea
31b3b00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //! Common traits for event senders and receivers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use embassy_sync::channel::{DynamicReceiver, DynamicSender}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Common event sender trait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub trait Sender<E> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Attempt to send an event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Return none if the event cannot currently be sent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn try_send(&mut self, event: E) -> Option<()>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Send an event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn send(&mut self, event: E) -> impl Future<Output = ()>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+13
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Common event receiver trait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub trait Receiver<E> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Attempt to receive an event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Return none if there are no pending events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn try_next(&mut self) -> Option<E>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Receiver an event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+5
to
+21
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Common event sender trait | |
| pub trait Sender<E> { | |
| /// Attempt to send an event | |
| /// | |
| /// Return none if the event cannot currently be sent | |
| fn try_send(&mut self, event: E) -> Option<()>; | |
| /// Send an event | |
| fn send(&mut self, event: E) -> impl Future<Output = ()>; | |
| } | |
| /// Common event receiver trait | |
| pub trait Receiver<E> { | |
| /// Attempt to receive an event | |
| /// | |
| /// Return none if there are no pending events | |
| fn try_next(&mut self) -> Option<E>; | |
| /// Receiver an event | |
| /// Abstraction over components that can send events of type `E`. | |
| /// | |
| /// This trait provides a common interface for event senders backed by | |
| /// channel-like primitives (for example, [`DynamicSender`]). It allows code | |
| /// to be written against this trait instead of a concrete channel type. | |
| /// | |
| /// # Semantics | |
| /// | |
| /// - [`Sender::try_send`] is **non-blocking**: it attempts to enqueue an | |
| /// event immediately and returns: | |
| /// - `Some(())` if the event was successfully enqueued. | |
| /// - `None` if the event cannot currently be sent. In this crate's | |
| /// implementations, this covers both the channel being full and the | |
| /// receiver side being closed. | |
| /// - [`Sender::send`] returns a future that will **asynchronously** send | |
| /// the event according to the underlying implementation's semantics. | |
| pub trait Sender<E> { | |
| /// Attempt to send an event without blocking. | |
| /// | |
| /// Returns `Some(())` on success. | |
| /// | |
| /// Returns `None` if the event cannot currently be sent. For the | |
| /// provided `DynamicSender` implementation, this occurs when the | |
| /// underlying channel is full or the receiver side has been closed. | |
| fn try_send(&mut self, event: E) -> Option<()>; | |
| /// Send an event, waiting asynchronously until it can be enqueued. | |
| /// | |
| /// The returned future completes once the event has been sent according | |
| /// to the semantics of the underlying sender implementation. | |
| fn send(&mut self, event: E) -> impl Future<Output = ()>; | |
| } | |
| /// Abstraction over components that can receive events of type `E`. | |
| /// | |
| /// This trait provides a common interface for event receivers backed by | |
| /// channel-like primitives (for example, [`DynamicReceiver`]). It allows | |
| /// consumers to be written against this trait instead of a concrete channel | |
| /// type. | |
| /// | |
| /// # Semantics | |
| /// | |
| /// - [`Receiver::try_next`] is **non-blocking**: it attempts to receive an | |
| /// event immediately and returns: | |
| /// - `Some(event)` if an event is available. | |
| /// - `None` if no event can currently be received. In this crate's | |
| /// implementations, this covers both the channel being empty and the | |
| /// sender side being closed. | |
| /// - [`Receiver::wait_next`] returns a future that will **asynchronously** | |
| /// wait for and yield the next event. | |
| pub trait Receiver<E> { | |
| /// Attempt to receive the next event without blocking. | |
| /// | |
| /// Returns `Some(event)` if an event is immediately available. | |
| /// | |
| /// Returns `None` if there are no pending events. For the provided | |
| /// `DynamicReceiver` implementation, this occurs when the underlying | |
| /// channel is empty or the sender side has been closed. | |
| fn try_next(&mut self) -> Option<E>; | |
| /// Receive the next event, waiting asynchronously until one is available. |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in documentation comment: "Receiver an event" should be "Receive an event".
| /// Receiver an event | |
| /// Receive an event |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment /// Receiver an event has a grammatical error ("Receiver" vs "Receive"). Consider updating it to /// Receive an event for clarity and consistency with surrounding documentation.
| /// Receiver an event | |
| /// Receive an event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import for Future. The trait methods return
impl Futurebut there's nouse core::future::Future;statement in this file.