pub struct FormData { /* private fields */ }Expand description
Parsed form body (application/x-www-form-urlencoded) or query string. Values are owned so handlers can move them into DB calls freely.
Duplicate keys (e.g. multi-checkbox forms posting status=active
alongside status=pending) are preserved by [get_all] but
collapsed to the last submitted value by [get] / [as_map] for
backward compatibility with handlers that expect a single string
per key.
Implementations§
Source§impl FormData
impl FormData
pub fn from_urlencoded(input: &str) -> Self
pub fn get(&self, key: &str) -> Option<&str>
Sourcepub fn get_all(&self, key: &str) -> &[String]
pub fn get_all(&self, key: &str) -> &[String]
All values submitted for key, in submission order. Returns
the empty slice when the key wasn’t submitted at all. Used by
multi-select filters where the same field name appears once
per checked option (?status=active&status=pending).
pub fn required(&self, key: &str) -> Result<&str>
pub fn bool_flag(&self, key: &str) -> bool
pub fn contains(&self, key: &str) -> bool
pub fn as_map(&self) -> &HashMap<String, String>
Sourcepub fn set(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set(&mut self, key: impl Into<String>, value: impl Into<String>)
Insert or overwrite a key. Used by the admin handlers to inject
existing values for readonly_fields before passing the form
to the model’s from_form (the field is rendered disabled so
the browser would otherwise omit it, breaking required parsing).
Resets the multi-value view to a single entry so get_all
stays consistent with get.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FormData
impl RefUnwindSafe for FormData
impl Send for FormData
impl Sync for FormData
impl Unpin for FormData
impl UnsafeUnpin for FormData
impl UnwindSafe for FormData
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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