[][src]Struct scrappy_multipart::Multipart

pub struct Multipart { /* fields omitted */ }

The server-side implementation of multipart/form-data requests.

This will parse the incoming stream into MultipartItem instances via its Stream implementation. MultipartItem::Field contains multipart field. MultipartItem::Multipart is used for nested multipart streams.

Methods

impl Multipart[src]

pub fn new<S>(headers: &HeaderMap, stream: S) -> Multipart where
    S: Stream<Item = Result<Bytes, PayloadError>> + Unpin + 'static, 
[src]

Create multipart instance for boundary.

Trait Implementations

impl FromRequest for Multipart[src]

Get request's payload as multipart stream

Content-type: multipart/form-data;

Server example

use futures::{Stream, StreamExt};
use scrappy::{web, HttpResponse, Error};
use scrappy_multipart as mp;

async fn index(mut payload: mp::Multipart) -> Result<HttpResponse, Error> {
    // iterate over multipart stream
    while let Some(item) = payload.next().await {
           let mut field = item?;

           // Field in turn is stream of *Bytes* object
           while let Some(chunk) = field.next().await {
               println!("-- CHUNK: \n{:?}", std::str::from_utf8(&chunk?));
           }
    }
    Ok(HttpResponse::Ok().into())
}

type Error = Error

The associated error which can be returned.

type Future = Ready<Result<Multipart, Error>>

Future that resolves to a Self

type Config = ()

Configuration for this extractor

impl Stream for Multipart[src]

type Item = Result<Field, MultipartError>

Values yielded by the stream.

Auto Trait Implementations

impl !RefUnwindSafe for Multipart

impl !Send for Multipart

impl !Sync for Multipart

impl Unpin for Multipart

impl !UnwindSafe for Multipart

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<St> StreamExt for St where
    St: Stream + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,