async fn next(&mut self) -> Option<Result<'r, Field<'r, 'i>>> {
        if self.done {
            return None;
        }

        let field = match self.source.next_field().await {
            Ok(Some(field)) => field,
            Ok(None) => return None,
            Err(e) => {
                self.done = true;
                return Some(Err(e.into()));
            }
        };

        // A field with a content-type is data; one without is "value".
        trace_!("multipart field: {:?}", field);
        let content_type = field.content_type().and_then(|m| m.as_ref().parse().ok());
        let field = if let Some(content_type) = content_type {
            let (name, file_name) = match (field.name(), field.file_name()) {
                (None, None) => ("", None),
                (None, Some(file_name)) => ("", Some(self.buffer.push(file_name))),
                (Some(name), None) => (self.buffer.push(name), None),
                (Some(a), Some(b)) => {
                    let (field_name, file_name) = self.buffer.push_two(a, b);
                    (field_name, Some(file_name))
                }
            };

            Either::Right(DataField {
                content_type,
                request: self.request,
                name: NameView::new(name),
                file_name: file_name.map(crate::fs::FileName::new),
                data: Data::from(field),
            })
        } else {
            let (mut buf, len) = match field.name() {
                Some(s) => (s.to_string(), s.len()),
                None => (String::new(), 0)
            };

            match field.text().await {
                Ok(text) => buf.push_str(&text),
                Err(e) => return Some(Err(e.into())),
            };

            let name_val = self.buffer.push_split(buf, len);
            Either::Left(ValueField::from(name_val))
        };

        Some(Ok(field))
    }
/// Returns `None` when there are no further fields. Otherwise tries to
/// parse the next multipart form field and returns the result.
Returns `None` when there are no further fields. Otherwise tries to
parse the next multipart form field and returns the result.
Returns ` None ` when there are no further fields . Otherwise tries to parse the next multipart form field and returns the result .
async fn next(&mut self) -> Option<Result<'r, Field<'r, 'i>>> {
        if self.done {
            return None;
        }
        let field = match self.source.next_field().await {
            Ok(Some(field)) => field,
            Ok(None) => return None,
            Err(e) => {
                self.done = true;
                return Some(Err(e.into()));
            }
        };
        // A field with a content-type is data; one without is "value".
        trace_!("multipart field: {:?}", field);
        let content_type = field.content_type().and_then(|m| m.as_ref().parse().ok());
        let field = if let Some(content_type) = content_type {
            let (name, file_name) = match (field.name(), field.file_name()) {
                (None, None) => ("", None),
                (None, Some(file_name)) => ("", Some(self.buffer.push(file_name))),
                (Some(name), None) => (self.buffer.push(name), None),
                (Some(a), Some(b)) => {
                    let (field_name, file_name) = self.buffer.push_two(a, b);
                    (field_name, Some(file_name))
                }
            };
            Either::Right(DataField {
                content_type,
                request: self.request,
                name: NameView::new(name),
                file_name: file_name.map(crate::fs::FileName::new),
                data: Data::from(field),
            })
        } else {
            let (mut buf, len) = match field.name() {
                Some(s) => (s.to_string(), s.len()),
                None => (String::new(), 0)
            };
            match field.text().await {
                Ok(text) => buf.push_str(&text),
                Err(e) => return Some(Err(e.into())),
            };
            let name_val = self.buffer.push_split(buf, len);
            Either::Left(ValueField::from(name_val))
        };
        Some(Ok(field))
    }
async fn next ( & mut self ) -> Option < Result < ' r , Field < ' r , ' i > > > { if self . done { return None ; } let field = match self . source . next_field ( ) . await { Ok ( Some ( field ) ) => field , Ok ( None ) => return None , Err ( e ) => { self . done = true ; return Some ( Err ( e . into ( ) ) ) ; } } ; // A field with a content-type is data; one without is "value". trace_ ! ( " " field ) ; let content_type = field . content_type ( ) . and_then ( | m | m . as_ref ( ) . parse ( ) . ok ( ) ) ; let field = if let Some ( content_type ) = content_type { let ( name , file_name ) = match ( field . name ( ) , field . file_name ( ) ) { ( None , None ) => ( " " , None ) , ( None , Some ( file_name ) ) => ( " " , Some ( self . buffer . push ( file_name ) ) ) , ( Some ( name ) , None ) => ( self . buffer . push ( name ) , None ) , ( Some ( a ) , Some ( b ) ) => { let ( field_name , file_name ) = self . buffer . push_two ( a , b ) ; ( field_name , Some ( file_name ) ) } } ; Either :: Right ( DataField { content_type , request : self . request , name : NameView :: new ( name ) , file_name : file_name . map ( crate :: fs :: FileName :: new ) , data : Data :: from ( field ) , } ) } else { let ( mut buf , len ) = match field . name ( ) { Some ( s ) => ( s . to_string ( ) , s . len ( ) ) , None => ( String :: new ( ) , 0 ) } ; match field . text ( ) . await { Ok ( text ) => buf . push_str ( & text ) , Err ( e ) => return Some ( Err ( e . into ( ) ) ) , } ; let name_val = self . buffer . push_split ( buf , len ) ; Either :: Left ( ValueField :: from ( name_val ) ) } ; Some ( Ok ( field ) ) }
Returns `None` when there are no further fields.
Returns ` None ` when there are no further fields .
&mut self
&mut self