Struct mpd_utils::PersistentClient
source · pub struct PersistentClient<'a> { /* private fields */ }Expand description
MPD client which automatically attempts to reconnect if the connection cannot be established or is lost.
Commands sent to a disconnected client are queued.
Implementations§
source§impl<'a> PersistentClient<'a>
impl<'a> PersistentClient<'a>
pub fn new(host: &'a str, retry_interval: Duration) -> Self
sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Gets whether there is a valid connection to the server
sourcepub async fn wait_for_client(&self) -> Arc<Client>
pub async fn wait_for_client(&self) -> Arc<Client>
Waits for a valid connection to the server to be established. If already connected, resolves immediately.
sourcepub async fn with_client<F, Fut, T>(&self, f: F) -> Twhere
F: FnOnce(Arc<Client>) -> Fut,
Fut: Future<Output = T>,
pub async fn with_client<F, Fut, T>(&self, f: F) -> Twhere F: FnOnce(Arc<Client>) -> Fut, Fut: Future<Output = T>,
Runs the provided callback as soon as the connected client is available.
sourcepub async fn recv(&self) -> Option<ConnectionEvent>
pub async fn recv(&self) -> Option<ConnectionEvent>
Receives an event from the MPD server.
sourcepub async fn status(&self) -> Result<Status, CommandError>
pub async fn status(&self) -> Result<Status, CommandError>
Runs the status command on the MPD server.
sourcepub async fn current_song(&self) -> Result<Option<SongInQueue>, CommandError>
pub async fn current_song(&self) -> Result<Option<SongInQueue>, CommandError>
Runs the currentsong command on the MPD server.