heph
heph copied to clipboard
Value selecting in inbox
Allows the user to select a message from the inbox.
impl<T> Receiver<T> {
pub fn try_select<S>(&self, selector: S) -> Result<T, RecvError>
where S: MessageSelector,
{
// ...
}
pub fn select<S>(&self, selector: S) -> SelectValue<'r, T> // Future<Output = Result<T, RecvError>>
where S: MessageSelector,
{
// ...
}
}
/// Select a message to receive.
pub trait MessageSelector<M> {
/// Select what message to receive.
fn select<'m>(&mut self, messages: Messages<'m, M>) -> Option<MessageSelection>;
}
/// The type used to indicate what message to select.
pub struct MessageSelection(usize);
/// Iterator for available messages.
pub struct Messages {
// ...
}