Skip to main content

Field

Struct Field 

Source
pub struct Field {
    pub name: String,
    pub label: String,
    pub field_type: FieldType,
    pub readonly: bool,
    pub hidden: bool,
    pub list_only: bool,
    pub form_only: bool,
    pub required: bool,
    pub help_text: Option<String>,
    pub validators: Vec<Box<dyn Validator>>,
    pub async_validators: Vec<Box<dyn AsyncValidator>>,
}

Fields§

§name: String§label: String§field_type: FieldType§readonly: bool§hidden: bool§list_only: bool§form_only: bool§required: bool§help_text: Option<String>§validators: Vec<Box<dyn Validator>>§async_validators: Vec<Box<dyn AsyncValidator>>

Implementations§

Source§

impl Field

Source

pub fn text(name: &str) -> Self

Source

pub fn textarea(name: &str) -> Self

Source

pub fn email(name: &str) -> Self

Source

pub fn password(name: &str) -> Self

Source

pub fn number(name: &str) -> Self

Source

pub fn float(name: &str) -> Self

Source

pub fn boolean(name: &str) -> Self

Source

pub fn date(name: &str) -> Self

Source

pub fn datetime(name: &str) -> Self

Source

pub fn json(name: &str) -> Self

Source

pub fn select(name: &str, options: Vec<(String, String)>) -> Self

Source

pub fn foreign_key( name: &str, label: &str, adapter: Box<dyn DataAdapter>, value_field: &str, label_field: &str, ) -> Self

Source

pub fn custom(name: &str, widget: Box<dyn Widget>) -> Self

Source

pub fn many_to_many(name: &str, adapter: Box<dyn ManyToManyAdapter>) -> Self

Source

pub fn file(name: &str, storage: Arc<dyn FileStorage>) -> Self

Source

pub fn image(name: &str, storage: Arc<dyn FileStorage>) -> Self

Source

pub fn accept(self, types: Vec<String>) -> Self

Set the accepted MIME types for a File field. Example: vec!["application/pdf".to_string()]. Has no effect on non-File fields.

Source

pub fn label(self, label: &str) -> Self

Source

pub fn readonly(self) -> Self

Source

pub fn hidden(self) -> Self

Source

pub fn list_only(self) -> Self

Source

pub fn form_only(self) -> Self

Source

pub fn required(self) -> Self

Source

pub fn help_text(self, text: &str) -> Self

Source

pub fn validator(self, v: Box<dyn Validator>) -> Self

Add a custom synchronous validator.

Source

pub fn async_validator(self, v: Box<dyn AsyncValidator>) -> Self

Add a custom asynchronous validator (e.g. uniqueness checks).

Source

pub fn min_length(self, n: usize) -> Self

Source

pub fn max_length(self, n: usize) -> Self

Source

pub fn min_value(self, n: f64) -> Self

Source

pub fn max_value(self, n: f64) -> Self

Source

pub fn regex(self, pattern: &str) -> Self

Source

pub fn unique(self, adapter: Box<dyn DataAdapter>, col: &str) -> Self

Source

pub fn fk_limit(self, n: u64) -> Self

Source

pub fn fk_order_by(self, field: &str) -> Self

Trait Implementations§

Source§

impl Debug for Field

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Field

§

impl !RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnsafeUnpin for Field

§

impl !UnwindSafe for Field

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,