Skip to main content

Request

Enum Request 

Source
pub enum Request<'a> {
Show 14 variants Get { key: &'a [u8], }, Gets { keys: &'a [&'a [u8]], }, Set { key: &'a [u8], value: &'a [u8], flags: u32, exptime: u32, }, Add { key: &'a [u8], value: &'a [u8], flags: u32, exptime: u32, }, Replace { key: &'a [u8], value: &'a [u8], flags: u32, exptime: u32, }, Incr { key: &'a [u8], delta: u64, }, Decr { key: &'a [u8], delta: u64, }, Append { key: &'a [u8], value: &'a [u8], }, Prepend { key: &'a [u8], value: &'a [u8], }, Cas { key: &'a [u8], value: &'a [u8], flags: u32, exptime: u32, cas_unique: u64, }, Delete { key: &'a [u8], }, FlushAll, Version, Quit,
}
Expand description

A request builder for encoding Memcache commands.

Variants§

§

Get

GET command: get <key>\r\n

Fields

§key: &'a [u8]
§

Gets

Multi-GET command: get <key1> <key2> ...\r\n

Fields

§keys: &'a [&'a [u8]]
§

Set

SET command: set <key> <flags> <exptime> <bytes>\r\n<data>\r\n

Fields

§key: &'a [u8]
§value: &'a [u8]
§flags: u32
§exptime: u32
§

Add

ADD command: add <key> <flags> <exptime> <bytes>\r\n<data>\r\n

Stores the item only if the key does not already exist.

Fields

§key: &'a [u8]
§value: &'a [u8]
§flags: u32
§exptime: u32
§

Replace

REPLACE command: replace <key> <flags> <exptime> <bytes>\r\n<data>\r\n

Stores the item only if the key already exists.

Fields

§key: &'a [u8]
§value: &'a [u8]
§flags: u32
§exptime: u32
§

Incr

INCR command: incr <key> <delta>\r\n

Fields

§key: &'a [u8]
§delta: u64
§

Decr

DECR command: decr <key> <delta>\r\n

Fields

§key: &'a [u8]
§delta: u64
§

Append

APPEND command: append <key> 0 0 <bytes>\r\n<data>\r\n

Appends data to an existing item’s value.

Fields

§key: &'a [u8]
§value: &'a [u8]
§

Prepend

PREPEND command: prepend <key> 0 0 <bytes>\r\n<data>\r\n

Prepends data to an existing item’s value.

Fields

§key: &'a [u8]
§value: &'a [u8]
§

Cas

CAS command: cas <key> <flags> <exptime> <bytes> <cas_unique>\r\n<data>\r\n

Compare-and-swap: stores only if the CAS token matches.

Fields

§key: &'a [u8]
§value: &'a [u8]
§flags: u32
§exptime: u32
§cas_unique: u64
§

Delete

DELETE command: delete <key>\r\n

Fields

§key: &'a [u8]
§

FlushAll

FLUSH_ALL command: flush_all\r\n

§

Version

VERSION command: version\r\n

§

Quit

QUIT command: quit\r\n

Implementations§

Source§

impl<'a> Request<'a>

Source

pub fn get(key: &'a [u8]) -> Self

Create a GET request.

Source

pub fn gets(keys: &'a [&'a [u8]]) -> Self

Create a multi-GET request.

Source

pub fn set(key: &'a [u8], value: &'a [u8]) -> SetRequest<'a>

Create a SET request.

Source

pub fn add(key: &'a [u8], value: &'a [u8]) -> AddRequest<'a>

Create an ADD request (store only if key does not exist).

Source

pub fn replace(key: &'a [u8], value: &'a [u8]) -> ReplaceRequest<'a>

Create a REPLACE request (store only if key already exists).

Source

pub fn incr(key: &'a [u8], delta: u64) -> Self

Create an INCR request.

Source

pub fn decr(key: &'a [u8], delta: u64) -> Self

Create a DECR request.

Source

pub fn append(key: &'a [u8], value: &'a [u8]) -> Self

Create an APPEND request.

Source

pub fn prepend(key: &'a [u8], value: &'a [u8]) -> Self

Create a PREPEND request.

Source

pub fn cas(key: &'a [u8], value: &'a [u8], cas_unique: u64) -> Self

Create a CAS (compare-and-swap) request.

Source

pub fn delete(key: &'a [u8]) -> Self

Create a DELETE request.

Source

pub fn flush_all() -> Self

Create a FLUSH_ALL request.

Source

pub fn version() -> Self

Create a VERSION request.

Source

pub fn quit() -> Self

Create a QUIT request.

Source

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

Encode this request into a buffer.

Returns the number of bytes written.

Trait Implementations§

Source§

impl<'a> Clone for Request<'a>

Source§

fn clone(&self) -> Request<'a>

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<'a> Debug for Request<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Request<'a>

§

impl<'a> RefUnwindSafe for Request<'a>

§

impl<'a> Send for Request<'a>

§

impl<'a> Sync for Request<'a>

§

impl<'a> Unpin for Request<'a>

§

impl<'a> UnsafeUnpin for Request<'a>

§

impl<'a> UnwindSafe for Request<'a>

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.