pub struct Request<'a> { /* private fields */ }Expand description
A request builder for encoding Redis commands.
This provides a fluent interface for building and encoding commands.
§Example
use resp_proto::Request;
let mut buf = vec![0u8; 1024];
// Simple GET
let len = Request::get(b"mykey").encode(&mut buf);
// SET with expiration
let len = Request::set(b"mykey", b"myvalue").ex(3600).encode(&mut buf);Implementations§
Source§impl<'a> Request<'a>
impl<'a> Request<'a>
Sourcepub fn set(key: &'a [u8], value: &'a [u8]) -> SetRequest<'a>
pub fn set(key: &'a [u8], value: &'a [u8]) -> SetRequest<'a>
Create a SET command.
Sourcepub fn config_get(key: &'a [u8]) -> Self
pub fn config_get(key: &'a [u8]) -> Self
Create a CONFIG GET command.
Sourcepub fn config_set(key: &'a [u8], value: &'a [u8]) -> Self
pub fn config_set(key: &'a [u8], value: &'a [u8]) -> Self
Create a CONFIG SET command.
Sourcepub fn cluster_slots() -> Self
pub fn cluster_slots() -> Self
Create a CLUSTER SLOTS command.
Sourcepub fn cluster_nodes() -> Self
pub fn cluster_nodes() -> Self
Create a CLUSTER NODES command.
Sourcepub fn cluster_info() -> Self
pub fn cluster_info() -> Self
Create a CLUSTER INFO command.
Sourcepub fn cluster_myid() -> Self
pub fn cluster_myid() -> Self
Create a CLUSTER MYID command.
Sourcepub fn encode(&self, buf: &mut [u8]) -> usize
pub fn encode(&self, buf: &mut [u8]) -> usize
Encode this request into a buffer.
Returns the number of bytes written.
§Panics
Panics if the buffer is too small.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Calculate the encoded length of this request.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more