[][src]Struct mpd_protocol::response::Response

pub struct Response { /* fields omitted */ }

Response to a command, consisting of an abitrary amount of frames, which are responses to individual commands, and optionally a single error.

Since an error terminates a command list, there can only be one error in a response.

Implementations

impl Response[src]

pub fn new(frames: Vec<Frame>, error: Option<Error>) -> Self[src]

Construct a new response.

let r = Response::new(vec![Frame::empty()], None);
assert_eq!(1, r.len());
assert!(r.is_success());

Panics

Panics if it is attempted to construct an empty response (i.e. both frames and error are empty). This should not occur during normal operation.

This example panics
// This panics:
Response::new(Vec::new(), None);

pub fn empty() -> Self[src]

Construct a new "empty" response. This is the simplest possible succesful response, consisting of a single empty frame.

let r = Response::empty();
assert_eq!(1, r.len());
assert!(r.is_success());

pub fn is_error(&self) -> bool[src]

Returns true if the response resulted in an error.

Even if this returns true, there may still be succesful frames in the response when the response is to a command list.

let r = Response::new(Vec::new(), Some(Error::default()));
assert!(r.is_error());

pub fn is_success(&self) -> bool[src]

Returns true if the response was entirely succesful (i.e. no errors).

let r = Response::new(vec![Frame::empty()], None);
assert!(r.is_success());

pub fn len(&self) -> usize[src]

Get the number of succesful frames in the response.

May be 0 if the response only consists of an error.

let r = Response::empty();
assert_eq!(r.len(), 1);

pub fn frames(&self) -> FramesRef<'_>

Notable traits for FramesRef<'a>

impl<'a> Iterator for FramesRef<'a> type Item = Result<&'a Frame, &'a Error>;
[src]

Create an iterator over references to the frames in the response.

let r = Response::empty();
let mut iter = r.frames();

assert_eq!(Some(Ok(&Frame::empty())), iter.next());

pub fn single_frame(self) -> Result<Frame, Error>[src]

Treat the response as consisting of a single frame or error.

Frames or errors beyond the first, if they exist, are silently discarded.

let r = Response::empty();
assert_eq!(Ok(Frame::empty()), r.single_frame());

Trait Implementations

impl Clone for Response[src]

impl Debug for Response[src]

impl Eq for Response[src]

impl<'a> IntoIterator for &'a Response[src]

type Item = Result<&'a Frame, &'a Error>

The type of the elements being iterated over.

type IntoIter = FramesRef<'a>

Which kind of iterator are we turning this into?

impl IntoIterator for Response[src]

type Item = Result<Frame, Error>

The type of the elements being iterated over.

type IntoIter = Frames

Which kind of iterator are we turning this into?

impl PartialEq<Response> for Response[src]

impl StructuralEq for Response[src]

impl StructuralPartialEq for Response[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.