Struct mbpr::Response
[−]
[src]
pub struct Response<'a> { /* fields omitted */ }
Memcached Response Packet
The whole thing
Methods
impl<'a> Response<'a>
[src]
fn parse(x: &'a [u8]) -> ParseResult<Response<'a>>
Parse a full response. Internal Key/Extra/Body fields are borrowed.
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).
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.
fn new(opcode: OpCode,
status: StatusField,
opaque: u32,
cas: u64,
extra: Option<&'a [u8]>,
key: Option<&'a [u8]>,
body: Option<&'a [u8]>)
-> Response<'a>
status: StatusField,
opaque: u32,
cas: u64,
extra: Option<&'a [u8]>,
key: Option<&'a [u8]>,
body: Option<&'a [u8]>)
-> Response<'a>
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.
fn rebuild(&mut self,
opcode: OpCode,
status: StatusField,
opaque: u32,
cas: u64,
extra: Option<&'a [u8]>,
key: Option<&'a [u8]>,
body: Option<&'a [u8]>)
opcode: OpCode,
status: StatusField,
opaque: u32,
cas: u64,
extra: Option<&'a [u8]>,
key: Option<&'a [u8]>,
body: Option<&'a [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.
fn get_opcode(&self) -> OpCode
fn get_opaque(&self) -> u32
fn get_cas(&self) -> u64
fn check_status(&self) -> Result<(), StatusField>
Check Status Field
If the condition StatusField::NoError
is set this
will return Ok(())
, if there is an error it will
return it in Err(StatusField::_)
All standard error codes are implemented.
fn has_extra(&self) -> bool
fn get_extra(&'a self) -> Option<&'a [u8]>
fn has_key(&self) -> bool
fn get_key(&'a self) -> Option<&'a [u8]>
fn get_key_str(&'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.
fn has_body(&self) -> bool
fn get_body(&'a self) -> Option<&'a [u8]>
fn to_owned(self) -> OwnedResponse
Consume this item and take ownership
If a field is Option::None
the resulting
vector will be a Vec::with_capacity(0)
which
does not allocate. So this method can be
cheap depending on the messages contents.
Trait Implementations
impl<'a> Clone for Response<'a>
[src]
fn clone(&self) -> Response<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> Debug for Response<'a>
[src]
impl<'a> PacketVal for Response<'a>
[src]
fn get_keylen(&self) -> usize
Get size of Packet's Key Field
fn get_bodylen(&self) -> usize
Get size of Packet's Body Field (Raw Data)
fn get_extralen(&self) -> usize
Get size of Packet's Extra Field (Flags, Arguments, Etc. command specific)
fn total_len(&self) -> usize
The total length of the packet