pub enum Params {
List(Vec<Value>),
Named(Map<String, Value>),
}Expand description
One action call’s parameters, as the browser sent them.
Variants§
List(Vec<Value>)
Positional parameters, in the order the action declared them.
Named(Map<String, Value>)
Named parameters, as {param: 'value'} sent them.
Implementations§
Source§impl Params
impl Params
Sourcepub fn from_json(value: Value) -> Result<Self>
pub fn from_json(value: Value) -> Result<Self>
Reads the parameters the browser sent, rejecting anything that is neither a list nor an object.
Sourcepub fn arg<T: DeserializeOwned>(&self, name: &str, index: usize) -> Result<T>
pub fn arg<T: DeserializeOwned>(&self, name: &str, index: usize) -> Result<T>
The parameter at index, or under name.
The macro-generated dispatch reads each declared parameter this way, so a browser that sends named parameters and one that sends positional ones both reach the same action.
Sourcepub fn optional<T: DeserializeOwned>(
&self,
name: &str,
index: usize,
) -> Result<Option<T>>
pub fn optional<T: DeserializeOwned>( &self, name: &str, index: usize, ) -> Result<Option<T>>
The parameter at index, or under name, or None when the browser sent neither, for an
optional parameter.
Sourcepub fn decode<T: DeserializeOwned>(self) -> Result<T>
pub fn decode<T: DeserializeOwned>(self) -> Result<T>
Decodes the whole parameter list into T, for actions that take one struct.
Trait Implementations§
impl StructuralPartialEq for Params
Auto Trait Implementations§
impl Forget for Params
impl Freeze for Paramswhere
*const u8 is !null: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
impl Move for Params
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnsafeUnpin for Paramswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
impl UnwindSafe for Params
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