Skip to main content

MethodArgs

Struct MethodArgs 

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

Decoder for the body of a struct method taking two or more arguments.

A single-argument method takes the request body as the argument, which is the shape the wire has always had. Beyond one argument the body carries the whole list, in either of two forms:

  • a JSON/BEVE array of exactly N values, positionally, or
  • an object keyed by parameter name, where a missing key decodes as null (so an Option<T> parameter may be omitted) and a repeated key takes its last value.

All three BEVE array encodings work: generic, typed, and complex. They are not read the same way — a generic array’s elements are self-contained values in the input and are sliced out as spans, while a typed or complex array’s element headers are supplied by the reader rather than present in the bytes, so those are pulled through structio::beve::Documents::array instead — but that is an implementation detail and not a wire distinction. A client encodes a homogeneous argument list however its library naturally would.

Generated code names this, and a hand-written RepeMethods impl that publishes a multi-argument method should too: it is what makes such a table accept the same two body shapes a derived one does, instead of inventing a third that no client of a derived struct would speak. That is why it is public and documented rather than hidden — it carries a wire contract, not an implementation detail.

§How it works without a tree

It used to split a serde_json::Value into owned Values. There is no tree now, so it does the same job by recording byte spans: one pass over the body notes where each element starts and ends, and next_arg parses one span into one argument. Nothing between the two is materialized, no key is copied, and an argument the caller never asks for is never parsed.

The spans borrow the frame, which is why this carries the body’s lifetime.

Implementations§

Source§

impl<'a> MethodArgs<'a>

Source

pub fn new( path: &'a str, names: &'a [&'a str], body: RequestBody<'a>, ) -> StructResult<Self>

Split body into the argument list for names.

Source

pub fn next_arg<T>(&mut self) -> StructResult<T>
where T: for<'de> ServableRead<'de> + Default,

Decode the next argument in declaration order.

Auto Trait Implementations§

§

impl<'a> Freeze for MethodArgs<'a>

§

impl<'a> RefUnwindSafe for MethodArgs<'a>

§

impl<'a> Send for MethodArgs<'a>

§

impl<'a> Sync for MethodArgs<'a>

§

impl<'a> Unpin for MethodArgs<'a>

§

impl<'a> UnsafeUnpin for MethodArgs<'a>

§

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