Skip to main content

Response

Enum Response 

Source
pub enum Response {
    Values(Vec<Value>),
    Stored,
    NotStored,
    Deleted,
    NotFound,
    Exists,
    Ok,
    Numeric(u64),
    Version(Vec<u8>),
    Error,
    ClientError(Vec<u8>),
    ServerError(Vec<u8>),
}
Expand description

A parsed Memcache response.

Variants§

§

Values(Vec<Value>)

Value response from GET (may contain multiple values for multi-get)

§

Stored

STORED response from SET

§

NotStored

NOT_STORED response from SET

§

Deleted

DELETED response from DELETE

§

NotFound

NOT_FOUND response from DELETE

§

Exists

EXISTS response from CAS

§

Ok

OK response (from flush_all, touch, etc.)

§

Numeric(u64)

Numeric response from INCR/DECR (the new value after the operation).

§

Version(Vec<u8>)

VERSION response

§

Error

Generic error

§

ClientError(Vec<u8>)

Client error with message

§

ServerError(Vec<u8>)

Server error with message

Implementations§

Source§

impl Response

Source

pub fn stored() -> Self

Create a STORED response.

Source

pub fn not_stored() -> Self

Create a NOT_STORED response.

Source

pub fn deleted() -> Self

Create a DELETED response.

Source

pub fn not_found() -> Self

Create a NOT_FOUND response.

Source

pub fn ok() -> Self

Create an OK response.

Source

pub fn numeric(value: u64) -> Self

Create a numeric response (from INCR/DECR).

Source

pub fn miss() -> Self

Create an empty VALUES response (cache miss).

Source

pub fn hit(key: &[u8], flags: u32, data: &[u8]) -> Self

Create a VALUES response with a single value (cache hit).

Source

pub fn error() -> Self

Create an ERROR response.

Source

pub fn client_error(msg: &[u8]) -> Self

Create a CLIENT_ERROR response.

Source

pub fn server_error(msg: &[u8]) -> Self

Create a SERVER_ERROR response.

Source

pub fn is_error(&self) -> bool

Returns true if this is an error response.

Source

pub fn is_miss(&self) -> bool

Returns true if this represents a cache miss.

Source

pub fn is_stored(&self) -> bool

Returns true if this is a successful storage response.

Source

pub fn parse(data: &[u8]) -> Result<(Self, usize), ParseError>

Parse a response from a byte buffer.

Returns the parsed response and the number of bytes consumed.

Source

pub fn encode(&self, buf: &mut [u8]) -> usize

Encode this response into a buffer.

Returns the number of bytes written.

Source

pub fn encode_stored(buf: &mut [u8]) -> usize

Encode STORED directly to buffer.

Source

pub fn encode_not_stored(buf: &mut [u8]) -> usize

Encode NOT_STORED directly to buffer.

Source

pub fn encode_deleted(buf: &mut [u8]) -> usize

Encode DELETED directly to buffer.

Source

pub fn encode_not_found(buf: &mut [u8]) -> usize

Encode NOT_FOUND directly to buffer.

Source

pub fn encode_end(buf: &mut [u8]) -> usize

Encode END (empty get response) directly to buffer.

Source

pub fn encode_value( buf: &mut [u8], key: &[u8], flags: u32, data: &[u8], ) -> usize

Encode a single VALUE response directly to buffer.

Source

pub fn encode_value_with_cas( buf: &mut [u8], key: &[u8], flags: u32, data: &[u8], cas: u64, ) -> usize

Encode a single VALUE response with CAS token directly to buffer (GETS response).

Format: VALUE <key> <flags> <bytes> <cas>\r\n<data>\r\nEND\r\n

Source

pub fn encode_exists(buf: &mut [u8]) -> usize

Encode EXISTS response directly to buffer.

Source

pub fn encode_numeric(buf: &mut [u8], value: u64) -> usize

Encode a numeric response directly to buffer (INCR/DECR result).

Source

pub fn encode_server_error(buf: &mut [u8], msg: &[u8]) -> usize

Encode a SERVER_ERROR response directly to buffer.

Trait Implementations§

Source§

impl Clone for Response

Source§

fn clone(&self) -> Response

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Response

Source§

fn eq(&self, other: &Response) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Response

Source§

impl StructuralPartialEq for Response

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.