Enum actix_form_data::Field [−][src]
pub enum Field { Array(Array), Map(Map), File(Arc<dyn Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Pin<Box<dyn Future<Output = Result<Option<PathBuf>, Error>>>> + Send + Sync>), Bytes, Int, Float, Text, }
The field type represents a field in the form-data that is allowed to be parsed.
Variants
File(Arc<dyn Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Pin<Box<dyn Future<Output = Result<Option<PathBuf>, Error>>>> + Send + Sync>)
Implementations
impl Field
[src]
pub fn file<F, Fut, E>(f: F) -> Self where
F: Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<Option<PathBuf>, E>> + 'static,
E: Into<Error> + 'static,
[src]
F: Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Fut + Send + Sync + Clone + 'static,
Fut: Future<Output = Result<Option<PathBuf>, E>> + 'static,
E: Into<Error> + 'static,
Add a File field with a name generator.
The name generator will be called for each file matching this field’s key. Keep in mind that each key/file pair will have it’s own name-generator, so sharing a name-generator between fields is up to the user.
Example
let (tx, rx) = channel(1); let form = Form::new().field("file-field", Field::file(move |_, _, mut stream| { let mut tx = tx.clone(); async move { while let Some(res) = stream.next().await { if let Ok(bytes) = res { if let Err(_) = tx.send(bytes).await { break; } } } Ok(None) as Result<_, std::convert::Infallible> } }));
pub fn bytes() -> Self
[src]
pub fn text() -> Self
[src]
pub fn int() -> Self
[src]
pub fn float() -> Self
[src]
pub fn array(field: Field) -> Self
[src]
Add an Array to a form
Example
let form = Form::new() .field( "array-field", Field::array(Field::text()) );
pub fn map() -> Map
[src]
Add a Map to a form
Example
let form = Form::new() .field( "map-field", Field::map() .field("sub-field", Field::text()) .field("sub-field-two", Field::text()) .finalize() );
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl !UnwindSafe for Field
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,