use super::{super::ControlKind, FileField};
impl<F> FileField<F> {
pub fn extensions<I>(mut self, extensions: I) -> Self
where
I: IntoIterator,
I::Item: AsRef<str>,
{
let extensions = extensions
.into_iter()
.map(|ext| {
let ext = ext.as_ref().trim();
ext.strip_prefix('.').unwrap_or(ext).to_ascii_lowercase()
})
.collect();
if let ControlKind::File(file) = &mut self.0.control {
file.extensions = Some(extensions);
}
self
}
pub fn max_bytes(mut self, max_bytes: usize) -> Self {
if let ControlKind::File(file) = &mut self.0.control {
file.max_bytes = Some(max_bytes);
}
self
}
}