Struct OwnedRequest

Source
pub struct OwnedRequest {
    pub key: Vec<u8>,
    pub extra: Vec<u8>,
    pub body: Vec<u8>,
    /* private fields */
}
Expand description

Clones Buffers

This behaves identical to Request other then the fact that the internal body/key/extra fields are owned vectors NOT borrowed slices.

This makes life a lot easier when working with the borrow checker, and concurrent programming.

Fields§

§key: Vec<u8>§extra: Vec<u8>§body: Vec<u8>

Implementations§

Source§

impl OwnedRequest

Source

pub fn parse(x: &[u8]) -> ParseResult<Self>

Reads a full packet and COPIES it’s buffers into its own. Allocation is lazy. Fields that are not used are not allocated. Fields are not allocated WHILE parsing, only when complete.

Source

pub fn new( opcode: OpCode, vbucket: u16, opaque: u32, cas: u64, extra: Vec<u8>, key: Vec<u8>, body: Vec<u8>, ) -> Self

This interface does ABSOLUTELY NO verfication of the packet it is expected if you are calling this method you understand the memcached protocol and you are going to use this to generate a valid packet.

The goal of this interface is to be fast. Encoding a packet with this interface + Encode trait involves very few branches

Memcached only allows Keys that are ASCII and non-white space this interface does not do ANY assertions of this. Please be aware.

Source

pub fn rebuild( &mut self, opcode: OpCode, vbucket: u16, opaque: u32, cas: u64, extra: Vec<u8>, key: Vec<u8>, body: Vec<u8>, )

Over write an existing request

This is provided to allow for easier interfacing with SLAB’s. The semantics of this method are identical to the above. The primary difference is this doesn’t push ~100 bytes to the stack.

This interface does ABSOLUTELY NO verfication of the packet it is expected if you are calling this method you understand the memcached protocol and you are going to use this to generate a valid packet.

The goal of this interface is to be fast. Encoding a packet with this interface + Encode trait involves very few branches

Memcached only allows Keys that are ASCII and non-white space this interface does not do ANY assertions of this. Please be aware.

Source

pub fn encode_self(&self) -> Encoder

Allocates a new buffer and encodes this packets contents into it. this method works out to a handful of memcp primatives and is fairly quick as their is no bounds checking (buffer length is asserted on construction).

Source

pub fn encode_into_buffer(&self, x: Vec<u8>) -> Encoder

If you are using a slab to avoid making too many allocations this method will check check the Vec<u8> it is passed only reserving additional capacity if necessary. If the Vec<u8> has enough capacity no action is taken.

Source

pub fn get_opcode(&self) -> OpCode

Source

pub fn get_opaque(&self) -> u32

Source

pub fn get_cas(&self) -> u64

Source

pub fn get_vbucket_id(&self) -> u16

Source

pub fn has_extra(&self) -> bool

Source

pub fn get_extra<'a>(&'a self) -> Option<&'a [u8]>

Source

pub fn has_key(&self) -> bool

Source

pub fn get_key<'a>(&'a self) -> Option<&'a [u8]>

Source

pub fn get_key_str<'a>(&'a self) -> Option<&'a str>

The standard states the key should be an ASCII compatible string so this method preforms that conversion without checking for correctness.

This isnt a problem as the key will be hash/stored as a byte buffer anyways.

This really only opens the door to non standard things.

Source

pub fn has_body(&self) -> bool

Source

pub fn get_body<'a>(&'a self) -> Option<&'a [u8]>

Trait Implementations§

Source§

impl Clone for OwnedRequest

Source§

fn clone(&self) -> OwnedRequest

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 Encoding for OwnedRequest

Source§

fn encode(&self, buffer: &mut Encoder)

Encode a packet

Source§

impl PacketVal for OwnedRequest

Source§

fn get_keylen(&self) -> usize

Get size of Packet’s Key Field

Source§

fn get_bodylen(&self) -> usize

Get size of Packet’s Body Field (Raw Data)

Source§

fn get_extralen(&self) -> usize

Get size of Packet’s Extra Field (Flags, Arguments, Etc. command specific)

Source§

fn total_len(&self) -> usize

The total length of the packet

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.