pub struct InputPort<'a> { /* private fields */ }
Expand description
Represents the input port of a PortMidi device.
Implementations
sourceimpl<'a> InputPort<'a>
impl<'a> InputPort<'a>
sourcepub fn new(
context: &'a PortMidi,
device: DeviceInfo,
buffer_size: usize
) -> Result<InputPort<'_>>
pub fn new(
context: &'a PortMidi,
device: DeviceInfo,
buffer_size: usize
) -> Result<InputPort<'_>>
Construct a new InputPort
for the given device and buffer size.
If the device
is not an input device an Error::NotAnInputDevice
is returned.
sourcepub fn read_n(&self, cnt: usize) -> Result<Option<Vec<MidiEvent>>>
pub fn read_n(&self, cnt: usize) -> Result<Option<Vec<MidiEvent>>>
Returns a Vec<MidiEvent>
with at most cnt
elements.
If there was no Midi event available, None
is returned.
If PortMidi fails to read from the device an Error::PortMidi(_)
is returned.
sourcepub fn read(&mut self) -> Result<Option<MidiEvent>>
pub fn read(&mut self) -> Result<Option<MidiEvent>>
Reads a single MidiEvent
if one is avaible.
A Result
of None
means no event was available.
sourcepub fn poll(&self) -> Result<bool>
pub fn poll(&self) -> Result<bool>
Polls for available Midi events.
Returns true
if there are events available, otherwise false
is returned.
If the polling fails an Error::PortMidi(_)
is returned.
sourcepub fn device(&self) -> DeviceInfo
pub fn device(&self) -> DeviceInfo
Returns the DeviceInfo
of the Midi device that owns this port.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for InputPort<'a>
impl<'a> !Sync for InputPort<'a>
impl<'a> Unpin for InputPort<'a>
impl<'a> UnwindSafe for InputPort<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more