Skip to main content

Argv

Struct Argv 

Source
pub struct Argv { /* private fields */ }
Expand description

A command’s arguments, and the decoder that fills them.

One per connection, reused for the life of the connection. After the first few commands it has the capacity it needs and never allocates again.

Implementations§

Source§

impl Argv

Source

pub fn new() -> Argv

An empty one.

Source

pub fn with_capacity(n: usize) -> Argv

An empty one with room for n arguments already reserved.

Worth doing at accept time. The first command on a connection is the only one that would otherwise allocate.

Source

pub fn reset(&mut self)

Forgets everything, including any half read command.

The connection calls this if it discards unread bytes for any reason, because the resume state is an offset into a buffer that is about to stop being the same buffer.

Source

pub fn len(&self) -> usize

How many arguments the last complete command had.

Source

pub fn is_empty(&self) -> bool

Whether the last complete command had no arguments.

Source

pub fn arg<'a>(&'a self, buf: &'a [u8], i: usize) -> Option<&'a [u8]>

Argument i, or None if there are fewer than that many.

buf must be the same buffer that was decoded and must not have been drained since.

Source

pub fn args<'a>(&'a self, buf: &'a [u8]) -> impl Iterator<Item = &'a [u8]>

Every argument in order.

Source

pub fn decode( &mut self, buf: &[u8], limits: &Limits, ) -> Result<Step, ProtocolError>

Reads one command from the front of buf.

§Errors

Any ProtocolError. Redis closes the connection after one of these and so should the caller: a protocol error means the two ends no longer agree on where the next frame starts, and there is no recovering from that by reading further.

Trait Implementations§

Source§

impl Debug for Argv

Source§

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

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

impl Default for Argv

Source§

fn default() -> Argv

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Argv

§

impl RefUnwindSafe for Argv

§

impl Send for Argv

§

impl Sync for Argv

§

impl Unpin for Argv

§

impl UnsafeUnpin for Argv

§

impl UnwindSafe for Argv

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSync for T

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.