[][src]Trait launchy::prelude::MsgPollingWrapper

pub trait MsgPollingWrapper {
    type Message;
    fn receiver(&self) -> &Receiver<Self::Message>;

    fn recv(&self) -> Self::Message { ... }
fn try_recv(&self) -> Option<Self::Message> { ... }
fn recv_timeout(&self, timeout: Duration) -> Option<Self::Message> { ... }
fn iter(&self) -> Iter<Self::Message> { ... }
fn iter_pending(&self) -> TryIter<Self::Message> { ... }
fn iter_for(&self, duration: Duration) -> IterFor<Self::Message> { ... }
fn iter_for_millis(&self, millis: u64) -> IterFor<Self::Message> { ... }
fn drain(&self) -> usize { ... } }

Associated Types

type Message

The type of message that is yielded

Loading content...

Required methods

fn receiver(&self) -> &Receiver<Self::Message>

Returns a std::sync::mpsc::Receiver that yields messages, where the type of messages is described by the associated Self::Message type

Loading content...

Provided methods

fn recv(&self) -> Self::Message

Wait for a message to arrive, and return that. For a non-block variant, see Self::try_recv.

fn try_recv(&self) -> Option<Self::Message>

If there is a pending message, return that. Otherwise, return None.

This function does not block.

fn recv_timeout(&self, timeout: Duration) -> Option<Self::Message>

Receives a single message. If no message arrives within the timespan specified by timeout, None is returned.

fn iter(&self) -> Iter<Self::Message>

Returns an iterator over all arriving messages. The iterator will only return when the MIDI connection has been dropped.

For an iteration method that doesn't block, but returns immediately when there are no more pending messages, see Self::iter_pending.

fn iter_pending(&self) -> TryIter<Self::Message>

Returns an iterator over the currently pending messages. As soon as all pending messages have been iterated over, the iterator will return.

For an iteration method that will block, waiting for new messages to arrive, see Self::iter.

fn iter_for(&self, duration: Duration) -> IterFor<Self::Message>

Returns an iterator that yields all arriving messages for a specified amount of time. After the specified duration has passed, the iterator will stop and not yield any more messages.

For a shorthand of this function that accepts the duration in milliseconds, see Self::iter_for_millis

fn iter_for_millis(&self, millis: u64) -> IterFor<Self::Message>

Returns an iterator that yields all arriving messages for a specified amount of time. After the specified duration has passed, the iterator will stop and not yield any more messages.

For a more general version of this function that accepts any std::time::Duration, see Self::iter_for

fn drain(&self) -> usize

Drain of any pending messages. This is useful on Launchpad startup - the Launchpad has the weird property that any button inputs while disconnected queue up and will all be released at the same time as soon as someone connects to it. In most cases you don't want to deal with those stale messages though - in those cases, call drain() after establishing the connection.

This function returns the number of messages that were discarded.

This is equivalent to self.iter_pending().count().

Loading content...

Implementors

impl MsgPollingWrapper for CanvasLayoutPoller[src]

impl MsgPollingWrapper for DeviceCanvasPoller[src]

impl<Message> MsgPollingWrapper for InputDeviceHandlerPolling<Message>[src]

type Message = Message

Loading content...