pub struct Argv { /* private fields */ }Expand description
A parsed command’s argument vector.
Stored in two allocations — all argument bytes concatenated in buf,
with ends[i] the end offset of argument i — instead of the N+1 a
Vec<Vec<u8>> needs (one outer Vec plus one per argument). Parsing a SET
drops from 4 allocations to 2. It is Send (two Vecs), so the
thread-per-core runtime still forwards it across cores by value.
Index/get/first/iter return &[u8] argument slices. It compares equal
to a Vec<Vec<u8>> of the same arguments, so call sites and tests read
naturally.
Implementations§
Source§impl Argv
impl Argv
Sourcepub fn with_capacity(argc: usize, bytes: usize) -> Self
pub fn with_capacity(argc: usize, bytes: usize) -> Self
An empty argv, pre-sizing for argc args totalling bytes bytes.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drop all args while keeping the buf + ends capacity. Used by the
reactor’s per-command scratch Argv: parse_command_into clears
then refills, so the hot path’s malloc rate drops to ~0.
Sourcepub fn reserve_for(&mut self, argc: usize, bytes: usize)
pub fn reserve_for(&mut self, argc: usize, bytes: usize)
Reserve room for argc args totalling bytes bytes on top of what is
already there (no shrink).
Trait Implementations§
Source§impl ArgvView for Argv
impl ArgvView for Argv
Source§fn iter(&self) -> ArgvIter<'_, Self> ⓘwhere
Self: Sized,
fn iter(&self) -> ArgvIter<'_, Self> ⓘwhere
Self: Sized,
impl Eq for Argv
Source§impl From<Vec<Vec<u8>>> for Argv
Build from a vec-of-vecs (test/embedding convenience; the wire path uses
parse_command, which builds an Argv directly
without the intermediate allocations).
impl From<Vec<Vec<u8>>> for Argv
Build from a vec-of-vecs (test/embedding convenience; the wire path uses
parse_command, which builds an Argv directly
without the intermediate allocations).