heph icon indicating copy to clipboard operation
heph copied to clipboard

Value selecting in inbox

Open Thomasdezeeuw opened this issue 2 years ago • 0 comments

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 {
    // ...
}

Thomasdezeeuw avatar Nov 01 '21 12:11 Thomasdezeeuw