pub struct Connection<IO> { /* private fields */ }Expand description
A blocking connection to an MPD server.
Implementations§
Source§impl<IO> Connection<IO>
impl<IO> Connection<IO>
Sourcepub fn connect(io: IO) -> Result<Connection<IO>, MpdProtocolError>where
IO: Read,
pub fn connect(io: IO) -> Result<Connection<IO>, MpdProtocolError>where
IO: Read,
Connect to an MPD server synchronously.
Sourcepub fn send_list(
&mut self,
command_list: CommandList,
) -> Result<(), MpdProtocolError>where
IO: Write,
pub fn send_list(
&mut self,
command_list: CommandList,
) -> Result<(), MpdProtocolError>where
IO: Write,
Sourcepub fn receive(&mut self) -> Result<Option<Response>, MpdProtocolError>where
IO: Read,
pub fn receive(&mut self) -> Result<Option<Response>, MpdProtocolError>where
IO: Read,
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 fn command(
&mut self,
command: Command,
) -> Result<Response, MpdProtocolError>
pub fn command( &mut self, command: Command, ) -> Result<Response, MpdProtocolError>
Send a command and receive its response.
This is essentially a shorthand for Connection::send followed by Connection::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 command_list(
&mut self,
command_list: CommandList,
) -> Result<Response, MpdProtocolError>
pub 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 Connection::send_list followed by Connection::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> Freeze for Connection<IO>where
IO: Freeze,
impl<IO> RefUnwindSafe for Connection<IO>where
IO: RefUnwindSafe,
impl<IO> Send for Connection<IO>where
IO: Send,
impl<IO> Sync for Connection<IO>where
IO: Sync,
impl<IO> Unpin for Connection<IO>where
IO: Unpin,
impl<IO> UnwindSafe for Connection<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