Skip to main content

ArgvBorrowed

Struct ArgvBorrowed 

Source
pub struct ArgvBorrowed<'a> { /* private fields */ }
Expand description

A parsed command’s argument vector that borrows its bytes from a contiguous input buffer.

Unlike Argv, which packs all argument bytes into a fresh Vec<u8>, ArgvBorrowed stores only a (start, end) table over the original buffer. get(i) returns &input[s..e], so no copy happens on the parse → dispatch path. Calls that need to outlive the buffer (cross-shard, MULTI queue, AOF) use into_owned to convert to Argv.

A5 (2026-06-20): the range table is a (u32, u32) × 4 inline + heap-spill InlineRanges. Commands with ≤4 args (PING/GET/SET/INCR/MGET ≤4 keys — the vast majority of the -c1 hot mix) pay zero malloc/free for the ranges. H1 (perf c2c) confirmed libc cfree on the per-request Vec allocation showed up in cross-thread contention; the inline tier removes that source.

Implementations§

Source§

impl<'a> ArgvBorrowed<'a>

Source

pub fn new(input: &'a [u8]) -> ArgvBorrowed<'a>

An empty argv that will read arg bytes from input.

Source

pub fn with_capacity(input: &'a [u8], argc: usize) -> ArgvBorrowed<'a>

An empty argv, pre-sizing ranges for argc args.

Source

pub fn len(&self) -> usize

Number of arguments.

Source

pub fn is_empty(&self) -> bool

Whether there are no arguments.

Source

pub fn get(&self, i: usize) -> Option<&[u8]>

Argument i as a byte slice into the original input, or None.

Source

pub fn first(&self) -> Option<&[u8]>

The first argument (the command name), or None if empty.

Source

pub fn iter(&self) -> impl Iterator<Item = &[u8]>

Iterate the arguments as byte slices into the original input.

Source

pub fn into_owned(self) -> Argv

Materialise an owned Argv — copies arg bytes into a fresh buffer. Used at any handoff juncture (cross-shard dispatch, MULTI queue, AOF logging) that needs to outlive the original input buffer.

Trait Implementations§

Source§

impl ArgvView for ArgvBorrowed<'_>

Source§

fn len(&self) -> usize

Number of arguments.
Source§

fn get(&self, i: usize) -> Option<&[u8]>

Argument i as a byte slice, or None if out of range.
Source§

fn is_empty(&self) -> bool

Whether there are no arguments.
Source§

fn first(&self) -> Option<&[u8]>

The first argument (the command name), or None if empty.
Source§

fn iter(&self) -> ArgvIter<'_, Self>
where Self: Sized,

Iterate the arguments as byte slices.
Source§

fn copy_into(&self, out: &mut Argv)

Clear out and refill it with this view’s arguments. out keeps its buffer capacity across the clear, so refilling a recycled Argv (see crate::ArgvPool) is allocation-free in steady state. Object-safe (no Self: Sized bound).
Source§

fn to_argv(&self) -> Argv

Materialise an owned Argv — copies arg bytes into a fresh buffer. Used at handoff junctures (cross-shard dispatch, MULTI queue, AOF logging) that need to outlive the original input buffer. Object-safe (no Self: Sized bound) so callers can hold &dyn ArgvView.
Source§

impl<'a> Clone for ArgvBorrowed<'a>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ArgvBorrowed<'a>

Source§

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

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

impl Index<usize> for ArgvBorrowed<'_>

Source§

type Output = [u8]

The returned type after indexing.
Source§

fn index(&self, i: usize) -> &[u8]

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq<Vec<Vec<u8>>> for ArgvBorrowed<'_>

Source§

fn eq(&self, other: &Vec<Vec<u8>>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'a> Freeze for ArgvBorrowed<'a>

§

impl<'a> RefUnwindSafe for ArgvBorrowed<'a>

§

impl<'a> Send for ArgvBorrowed<'a>

§

impl<'a> Sync for ArgvBorrowed<'a>

§

impl<'a> Unpin for ArgvBorrowed<'a>

§

impl<'a> UnsafeUnpin for ArgvBorrowed<'a>

§

impl<'a> UnwindSafe for ArgvBorrowed<'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.