pub struct Form { /* private fields */ }Implementations§
Source§impl Form
impl Form
Sourcepub fn default() -> Self
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();Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance of the struct with default values.
§Examples
let instance = StructName::new();Sourcepub fn build(self) -> Result<Self, String>
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 isOkif the JSON value could be deserialized into the struct, orErrif 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)
};Sourcepub fn user<Darth: Into<String>>(self, new: Darth) -> Self
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.Darthis 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();Sourcepub fn email<Darth: Into<String>>(self, new: Darth) -> Self
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.Darthis 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();Sourcepub fn password<Darth: Into<String>>(self, new: Darth) -> Self
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.Darthis 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();pub fn to_box(self) -> Box<Self>
pub fn to_rc(self) -> Rc<Self>
pub fn to_ref_cell(self) -> RefCell<Self>
pub fn to_rc_weak(self) -> Weak<Self>
Trait Implementations§
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> 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> 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