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

pub struct Response {
    pub frames: Vec<Frame>,
    pub error: Option<Error>,
}

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.

Fields

frames: Vec<Frame>

The sucessful responses.

error: Option<Error>

The error, if one occured.

Methods

impl Response[src]

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

Construct a new response.

use mpd_protocol::response::{Response, Frame};

let r = Response::new(vec![Frame::default()], None);
assert_eq!(1, r.frames.len());
assert!(r.error.is_none());

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.

use mpd_protocol::response::Response;

// 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.

use mpd_protocol::response::Response;

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

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

Returns true if the response resulted in an error.

use mpd_protocol::response::{Response, Error};

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).

use mpd_protocol::response::{Response, Frame};

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

Trait Implementations

impl Eq for Response[src]

impl PartialEq<Response> for Response[src]

impl Debug for Response[src]

impl StructuralPartialEq for Response[src]

impl StructuralEq for Response[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

type Error = !

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.

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

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

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