Struct mpd_protocol::AsyncConnection
source · pub struct AsyncConnection<IO>(/* private fields */);
Expand description
An asynchronous connection to an MPD server.
Implementations§
source§impl<IO> AsyncConnection<IO>
impl<IO> AsyncConnection<IO>
sourcepub async fn connect(io: IO) -> Result<AsyncConnection<IO>, MpdProtocolError>
Available on crate feature async
only.
pub async fn connect(io: IO) -> Result<AsyncConnection<IO>, MpdProtocolError>
async
only.Connect to an MPD server asynchronously.
§Errors
This will return an error if:
- Reading from the given IO resource returns an error
- A malformed greeting is received
- The connection is closed before a complete greeting could be read
sourcepub async fn send(&mut self, command: Command) -> Result<(), MpdProtocolError>where
IO: AsyncWrite + Unpin,
Available on crate feature async
only.
pub async fn send(&mut self, command: Command) -> Result<(), MpdProtocolError>where
IO: AsyncWrite + Unpin,
async
only.sourcepub async fn send_list(
&mut self,
command_list: CommandList
) -> Result<(), MpdProtocolError>where
IO: AsyncWrite + Unpin,
Available on crate feature async
only.
pub async fn send_list(
&mut self,
command_list: CommandList
) -> Result<(), MpdProtocolError>where
IO: AsyncWrite + Unpin,
async
only.sourcepub async fn receive(&mut self) -> Result<Option<Response>, MpdProtocolError>
Available on crate feature async
only.
pub async fn receive(&mut self) -> Result<Option<Response>, MpdProtocolError>
async
only.Receive a response from the server.
This will return Ok(Some(..))
when a complete response has been received, or Ok(None)
if
the connection is closed cleanly.
§Errors
This will return an error if:
- Reading from the given IO resource returns an error
- Malformed response data is received
- The connection is closed while a response is in progress
sourcepub async fn command(
&mut self,
command: Command
) -> Result<Response, MpdProtocolError>
pub async fn command( &mut self, command: Command ) -> Result<Response, MpdProtocolError>
Send a command and receive its response.
This is essentially a shorthand for AsyncConnection::send
followed by
AsyncConnection::receive
.
§Errors
This will return an error if:
- Writing to or reading from the connection returns an error
- Malformed response data is received
- The connection is closed
sourcepub async fn command_list(
&mut self,
command_list: CommandList
) -> Result<Response, MpdProtocolError>
pub async fn command_list( &mut self, command_list: CommandList ) -> Result<Response, MpdProtocolError>
Send a command list and receive its response(s).
This is essentially a shorthand for AsyncConnection::send_list
followed by
AsyncConnection::receive
.
§Errors
This will return an error if:
- Writing to or reading from the connection returns an error
- Malformed response data is received
- The connection is closed
sourcepub fn protocol_version(&self) -> &str
pub fn protocol_version(&self) -> &str
Returns the protocol version the server is using.
sourcepub fn into_inner(self) -> IO
pub fn into_inner(self) -> IO
Extract the connection instance.
Trait Implementations§
Auto Trait Implementations§
impl<IO> RefUnwindSafe for AsyncConnection<IO>where
IO: RefUnwindSafe,
impl<IO> Send for AsyncConnection<IO>where
IO: Send,
impl<IO> Sync for AsyncConnection<IO>where
IO: Sync,
impl<IO> Unpin for AsyncConnection<IO>where
IO: Unpin,
impl<IO> UnwindSafe for AsyncConnection<IO>where
IO: UnwindSafe,
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