pub struct Params { /* private fields */ }Expand description
A wrapper around a JSON params object supporting require/permit.
Implementations§
Source§impl Params
impl Params
Sourcepub fn require(&self, key: &str) -> Result<Params>
pub fn require(&self, key: &str) -> Result<Params>
Return the nested params under key, erroring if it is absent (Rails
params.require(:key)).
Sourcepub fn permit(&self, allowed: &[&str]) -> Params
pub fn permit(&self, allowed: &[&str]) -> Params
Keep only the listed top-level keys, dropping everything else (Rails
params.permit(:a, :b)). Non-object params become an empty object.
Sourcepub fn deserialize<T: DeserializeOwned>(&self) -> Result<T>
pub fn deserialize<T: DeserializeOwned>(&self) -> Result<T>
Deserialize the (typically permitted) params into a typed value.
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Consume into the underlying JSON value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Params
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnsafeUnpin for Params
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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