pub struct GenericField {
pub kind: FieldKind,
}Expand description
Type-erased wrapper around any concrete field type (TextField,
NumericField, FileField, …), dispatching every FormField call to
the wrapped kind via delegate_to_kind!. Lets Forms store a single
heterogeneous collection of fields.
Fields§
§kind: FieldKindTrait Implementations§
Source§impl Clone for GenericField
impl Clone for GenericField
Source§impl CommonFieldConfig for GenericField
impl CommonFieldConfig for GenericField
fn get_field_config(&self) -> &FieldConfig
fn get_field_config_mut(&mut self) -> &mut FieldConfig
Source§fn is_password(&self) -> bool
fn is_password(&self) -> bool
true if the field’s value must never be exposed. Read moreSource§impl Debug for GenericField
impl Debug for GenericField
Source§impl FormField for GenericField
impl FormField for GenericField
fn name(&self) -> &str
fn label(&self) -> &str
fn value(&self) -> &str
fn placeholder(&self) -> &str
fn field_type(&self) -> &str
fn template_name(&self) -> &str
fn required(&self) -> bool
fn error(&self) -> Option<&String>
fn set_name(&mut self, name: &str)
fn set_label(&mut self, label: &str)
fn set_value(&mut self, value: &str)
Source§fn set_submitted_value(&mut self, value: &str)
fn set_submitted_value(&mut self, value: &str)
Sets a value that came from the request (
Forms::fill), as opposed to
one set by code. Same as set_value unless the field has to check where
the value comes from — a file field only takes a path to a file this
request uploaded.Source§fn set_type_bounds(&mut self, min: i128, max: i128) -> bool
fn set_type_bounds(&mut self, min: i128, max: i128) -> bool
Holds an integer field to what its Rust column type can store.
false
if this isn’t an integer field.Source§fn bounds(&self) -> FieldBounds
fn bounds(&self) -> FieldBounds
The lengths or values this field accepts; none by default.
Source§fn cap_max_size(&mut self, bytes: u64)
fn cap_max_size(&mut self, bytes: u64)
Lowers the accepted upload size to the column’s, if the field allows more.
Source§fn model_max_size(&self) -> Option<u64>
fn model_max_size(&self) -> Option<u64>
Model-defined ceiling for max_size (file fields only). None for other field types.
Source§fn set_max_size_bounded(&mut self, size: FileSize) -> Result<(), String>
fn set_max_size_bounded(&mut self, size: FileSize) -> Result<(), String>
Overrides the effective max_size. Returns Err if it exceeds the model ceiling.
fn set_placeholder(&mut self, placeholder: &str)
fn set_error(&mut self, error: String)
fn set_html_attribute(&mut self, key: &str, value: &str)
fn set_required(&mut self, required: bool, msg: Option<&str>)
fn set_readonly(&mut self, readonly: bool, msg: Option<&str>)
fn set_disabled(&mut self, disabled: bool, msg: Option<&str>)
Source§fn validate<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn validate<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Field-type specific validation
fn to_json_value(&self) -> Value
fn to_json_required(&self) -> Value
fn to_json_attributes(&self) -> Value
fn to_json_meta(&self) -> Value
Source§fn finalize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn finalize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Finalization (e.g., password hashing)
Source§fn clear_error(&mut self)
fn clear_error(&mut self)
Resets the field error (explicit equivalent of
set_error(""))Source§fn base_context(&self) -> Context
fn base_context(&self) -> Context
Rendering context shared by every field. Read more
fn to_json_readonly(&self) -> Value
fn to_json_disabled(&self) -> Value
Source§impl From<BinaryField> for GenericField
impl From<BinaryField> for GenericField
Source§fn from(f: BinaryField) -> Self
fn from(f: BinaryField) -> Self
Converts to this type from the input type.
Source§impl From<BooleanField> for GenericField
impl From<BooleanField> for GenericField
Source§fn from(f: BooleanField) -> Self
fn from(f: BooleanField) -> Self
Converts to this type from the input type.
Source§impl From<CheckboxField> for GenericField
impl From<CheckboxField> for GenericField
Source§fn from(f: CheckboxField) -> Self
fn from(f: CheckboxField) -> Self
Converts to this type from the input type.
Source§impl From<ChoiceField> for GenericField
impl From<ChoiceField> for GenericField
Source§fn from(f: ChoiceField) -> Self
fn from(f: ChoiceField) -> Self
Converts to this type from the input type.
Source§impl From<ColorField> for GenericField
impl From<ColorField> for GenericField
Source§fn from(f: ColorField) -> Self
fn from(f: ColorField) -> Self
Converts to this type from the input type.
Source§impl From<DateField> for GenericField
impl From<DateField> for GenericField
Source§impl From<DateTimeField> for GenericField
impl From<DateTimeField> for GenericField
Source§fn from(f: DateTimeField) -> Self
fn from(f: DateTimeField) -> Self
Converts to this type from the input type.
Source§impl From<DurationField> for GenericField
impl From<DurationField> for GenericField
Source§fn from(f: DurationField) -> Self
fn from(f: DurationField) -> Self
Converts to this type from the input type.
Source§impl From<FileField> for GenericField
impl From<FileField> for GenericField
Source§impl From<HiddenField> for GenericField
impl From<HiddenField> for GenericField
Source§fn from(f: HiddenField) -> Self
fn from(f: HiddenField) -> Self
Converts to this type from the input type.
Source§impl From<IPAddressField> for GenericField
impl From<IPAddressField> for GenericField
Source§fn from(f: IPAddressField) -> Self
fn from(f: IPAddressField) -> Self
Converts to this type from the input type.
Source§impl From<JSONField> for GenericField
impl From<JSONField> for GenericField
Source§impl From<NumericField> for GenericField
impl From<NumericField> for GenericField
Source§fn from(f: NumericField) -> Self
fn from(f: NumericField) -> Self
Converts to this type from the input type.
Source§impl From<RadioField> for GenericField
impl From<RadioField> for GenericField
Source§fn from(f: RadioField) -> Self
fn from(f: RadioField) -> Self
Converts to this type from the input type.
Source§impl From<SlugField> for GenericField
impl From<SlugField> for GenericField
Source§impl From<TextField> for GenericField
impl From<TextField> for GenericField
Source§impl From<TimeField> for GenericField
impl From<TimeField> for GenericField
Source§impl From<UUIDField> for GenericField
impl From<UUIDField> for GenericField
Auto Trait Implementations§
impl !RefUnwindSafe for GenericField
impl !UnwindSafe for GenericField
impl Freeze for GenericField
impl Send for GenericField
impl Sync for GenericField
impl Unpin for GenericField
impl UnsafeUnpin for GenericField
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,
Source§impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
Source§fn convert_into(self) -> T
fn convert_into(self) -> T
Infallibly converts a value of type
Self to a value of type T.Source§impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
Source§impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
Source§type Error = <T as ConvertTryFrom<F>>::Error
type Error = <T as ConvertTryFrom<F>>::Error
The type of an error that can occur during a conversion. Read more
Source§fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
Fallibly converts a value of type
Self to a value of type T.impl<T> ErasedDestructor for Twhere
T: 'static,
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
Compresses response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more
Source§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Insert a header into the request. Read more
Source§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Append a header into the request. Read more
Source§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
Insert a header into the request, if the header is not already present. Read more
Source§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Insert a header into the response. Read more
Source§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Append a header into the response. Read more
Source§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
Insert a header into the response, if the header is not already present. Read more