pub fn write_with_running_status<W: Write>(
        &self,
        running_status: &mut Option<u8>,
        out: &mut W,
    ) -> WriteResult<W> {
        match self {
            LiveEvent::Midi { channel, message } => {
                let status = message.status_nibble() << 4 | channel.as_int();
                if Some(status) != *running_status {
                    *running_status = Some(status);
                    out.write(&[status])?;
                }
                message.write(out)?;
            }
            LiveEvent::Common(common) => {
                *running_status = None;
                common.write(out)?;
            }
            LiveEvent::Realtime(realtime) => {
                out.write(&[realtime.encode()])?;
            }
        }
        Ok(())
    }
/// Write a message, skipping the status if it shares the status with the previous message.
///
/// Note that it's usually discouraged to feed messages with running status to OS APIs.
Write a message, skipping the status if it shares the status with the previous message.
Note that it's usually discouraged to feed messages with running status to OS APIs.
Write a message skipping the status if it shares the status with the previous message . Note that it ' s usually discouraged to feed messages with running status to OS APIs .
pub fn write_with_running_status<W: Write>(
        &self,
        running_status: &mut Option<u8>,
        out: &mut W,
    ) -> WriteResult<W> {
        match self {
            LiveEvent::Midi { channel, message } => {
                let status = message.status_nibble() << 4 | channel.as_int();
                if Some(status) != *running_status {
                    *running_status = Some(status);
                    out.write(&[status])?;
                }
                message.write(out)?;
            }
            LiveEvent::Common(common) => {
                *running_status = None;
                common.write(out)?;
            }
            LiveEvent::Realtime(realtime) => {
                out.write(&[realtime.encode()])?;
            }
        }
        Ok(())
    }
pub fn write_with_running_status < W : Write > ( & self , running_status : & mut Option < u8 > , out : & mut W , ) -> WriteResult < W > { match self { LiveEvent :: Midi { channel , message } => { let status = message . status_nibble ( ) << 4 | channel . as_int ( ) ; if Some ( status ) != * running_status { * running_status = Some ( status ) ; out . write ( & [ status ] ) ? ; } message . write ( out ) ? ; } LiveEvent :: Common ( common ) => { * running_status = None ; common . write ( out ) ? ; } LiveEvent :: Realtime ( realtime ) => { out . write ( & [ realtime . encode ( ) ] ) ? ; } } Ok ( ( ) ) }
Write a message, skipping the status if it shares the status with the previous message.
Write a message skipping the status if it shares the status with the previous message .
&self
running_status
&mut Option<u8>
out
&mut W
&self
running_status
&mut Option<u8>
out
&mut W