pub struct FileField {
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub max_length: Option<usize>,
pub allow_empty_file: bool,
pub max_size: u64,
}Expand description
FileField for file upload
Fields§
§name: String§label: Option<String>§required: bool§help_text: Option<String>§widget: Widget§initial: Option<Value>§max_length: Option<usize>§allow_empty_file: bool§max_size: u64Maximum file size in bytes. Defaults to 10 MB.
Implementations§
Source§impl FileField
impl FileField
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Create a new FileField
§Examples
use reinhardt_forms::fields::FileField;
let field = FileField::new("upload".to_string());
assert_eq!(field.name, "upload");
assert_eq!(field.max_size, 10 * 1024 * 1024);Sourcepub fn with_max_size(self, max_size: u64) -> Self
pub fn with_max_size(self, max_size: u64) -> Self
Set the maximum file size in bytes.
§Examples
use reinhardt_forms::fields::FileField;
let field = FileField::new("upload".to_string()).with_max_size(5 * 1024 * 1024);
assert_eq!(field.max_size, 5 * 1024 * 1024);Trait Implementations§
Source§impl FormField for FileField
impl FormField for FileField
fn name(&self) -> &str
fn label(&self) -> Option<&str>
fn required(&self) -> bool
fn help_text(&self) -> Option<&str>
fn widget(&self) -> &Widget
fn initial(&self) -> Option<&Value>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Auto Trait Implementations§
impl Freeze for FileField
impl RefUnwindSafe for FileField
impl Send for FileField
impl Sync for FileField
impl Unpin for FileField
impl UnsafeUnpin for FileField
impl UnwindSafe for FileField
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