pub struct IdleClient { /* private fields */ }Expand description
MPD client for “idle” connections.
§Introduction
This is an MPD client designed to “idle”: it opens a long-lived connection to the MPD server and waits for MPD to respond with a message indicating that there’s been a change to a subsystem of interest. At present, there are only two subsystems in which mpdpopm is interested: the player & messages (cf. IdleSubSystem).
use std::path::Path;
use tokio::runtime::Runtime;
use mpdpopm::clients::IdleClient;
let mut rt = Runtime::new().unwrap();
rt.block_on( async {
let mut client = IdleClient::open(Path::new("/var/run/mpd.sock")).await.unwrap();
client.subscribe("player").await.unwrap();
client.idle().await.unwrap();
// Arrives here when the player's state changes
})client is now a Future that
resolves to an IdleClient instance talking to /var/run/mpd.sock.
Implementations§
Source§impl IdleClient
impl IdleClient
Sourcepub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<IdleClient>
pub async fn connect<A: ToSocketAddrs>(addr: A) -> Result<IdleClient>
Create a new mpdpopm::client::IdleClient instance from something that implements ToSocketAddrs
pub async fn open<P: AsRef<Path>>(pth: P) -> Result<IdleClient>
pub fn new(stream: Box<dyn RequestResponse>) -> Result<IdleClient>
Sourcepub async fn idle(&mut self) -> Result<IdleSubSystem>
pub async fn idle(&mut self) -> Result<IdleSubSystem>
Enter idle state– return the subsystem that changed, causing the connection to return. NB this may block for some time.
Auto Trait Implementations§
impl Freeze for IdleClient
impl !RefUnwindSafe for IdleClient
impl !Send for IdleClient
impl !Sync for IdleClient
impl Unpin for IdleClient
impl !UnwindSafe for IdleClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more