Struct Form

Source
pub struct Form { /* private fields */ }

Implementations§

Source§

impl Form

Source

pub fn default() -> Self

Creates a new instance of the struct with default values for each field.

This method uses the Default trait to initialize each field of the struct. The Default trait provides a function default that returns the default value of the type.

§Returns
  • Self - A new instance of the struct with default values for each field.
§Examples
let instance = StructName::default();
Source

pub fn new() -> Self

Creates a new instance of the struct with default values.

§Examples
let instance = StructName::new();
Source

pub fn build(self) -> Result<Self, String>

Validates the struct fields based on the specified attributes and returns the struct instance if all validations pass. If any validation fails, it returns an error message.

The validation checks include:

  • Checking if the field value matches the specified pattern (if any).
  • Checking if the field value is greater than or equal to the specified minimum value (if any).
  • Checking if the field value is less than or equal to the specified maximum value (if any).
§Returns
  • Result<Self, String> - A result that is Ok if the JSON value could be deserialized into the struct, or Err if the JSON value is not an object or does not match the structure of the struct.
§Examples
 let obj = StructName::new().id(1).build();
 match obj {
     OK(ok) => println!("{:#?}", ok),
     Err(err) => println!("obj err: {}", err)
 };
Source

pub fn user<Darth: Into<String>>(self, new: Darth) -> Self

Sets the value of #field_name for the struct and returns the modified struct.

This method consumes the struct, modifies it, and then returns it for further chaining of method calls.

The new parameter is the new value for #field_name. It is generic and can be converted into the type of #field_name.

§Parameters
  • new: Darth - The new value for #field_name. Darth is any type that can be converted into the type of #field_name.
§Returns
  • Self - The modified struct.
§Examples
let instance = StructName::new()
    .#field_name(value)
    .build();
Source

pub fn email<Darth: Into<String>>(self, new: Darth) -> Self

Sets the value of #field_name for the struct and returns the modified struct.

This method consumes the struct, modifies it, and then returns it for further chaining of method calls.

The new parameter is the new value for #field_name. It is generic and can be converted into the type of #field_name.

§Parameters
  • new: Darth - The new value for #field_name. Darth is any type that can be converted into the type of #field_name.
§Returns
  • Self - The modified struct.
§Examples
let instance = StructName::new()
    .#field_name(value)
    .build();
Source

pub fn password<Darth: Into<String>>(self, new: Darth) -> Self

Sets the value of #field_name for the struct and returns the modified struct.

This method consumes the struct, modifies it, and then returns it for further chaining of method calls.

The new parameter is the new value for #field_name. It is generic and can be converted into the type of #field_name.

§Parameters
  • new: Darth - The new value for #field_name. Darth is any type that can be converted into the type of #field_name.
§Returns
  • Self - The modified struct.
§Examples
let instance = StructName::new()
    .#field_name(value)
    .build();
Source

pub fn to_box(self) -> Box<Self>

Source

pub fn to_rc(self) -> Rc<Self>

Source

pub fn to_ref_cell(self) -> RefCell<Self>

Source

pub fn to_rc_weak(self) -> Weak<Self>

Trait Implementations§

Source§

impl Debug for Form

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Form

§

impl RefUnwindSafe for Form

§

impl Send for Form

§

impl Sync for Form

§

impl Unpin for Form

§

impl UnwindSafe for Form

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

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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<El> ElementDescriptorBounds for El
where El: Debug,