Trait mpd::idle::Idle

source ·
pub trait Idle {
    type Stream: Read + Write;

    // Required method
    fn idle<'a>(
        &'a mut self,
        subsystems: &[Subsystem]
    ) -> Result<IdleGuard<'a, Self::Stream>, Error>;

    // Provided method
    fn wait(
        &mut self,
        subsystems: &[Subsystem]
    ) -> Result<Vec<Subsystem>, Error> { ... }
}
Expand description

This trait implements idle command of MPD protocol

See module’s documentation for details.

Required Associated Types§

source

type Stream: Read + Write

Stream type of a client

Required Methods§

source

fn idle<'a>( &'a mut self, subsystems: &[Subsystem] ) -> Result<IdleGuard<'a, Self::Stream>, Error>

Start listening for events from a set of subsystems

If empty subsystems slice is given, wait for all event from any subsystem.

This method returns IdleGuard, which takes mutable reference of an initial client, thus disallowing any operations on this mpd connection.

You can call .get() method of this struct to stop waiting and get all queued events matching given subsystems filter. This call consumes a guard, stops waiting and releases client object.

If the guard goes out of scope, wait lock is released as well, but all queued events will be silently ignored.

Provided Methods§

source

fn wait(&mut self, subsystems: &[Subsystem]) -> Result<Vec<Subsystem>, Error>

Wait for events from a set of subsystems and return list of affected subsystems

This is a blocking operation. If empty subsystems slice is given, wait for all event from any subsystem.

Implementors§

source§

impl<S: Read + Write> Idle for Client<S>

§

type Stream = S