pub struct FieldData<S: Stream> { /* private fields */ }Expand description
The data of a field in a multipart stream, as a stream of chunks.
It may be read to completion via the Stream impl, or collected to a string with read_text().
To avoid the next field being initialized before this one is done being read
(in a linear stream), only one instance per Multipart instance is allowed at a time.
A Drop implementation on FieldData is used to notify Multipart that this field is done
being read, thus:
§Warning About Leaks
If this value is leaked (via mem::forget() or some other mechanism), then the parent
Multipart will never be able to yield the next field in the stream. The task waiting on the
Multipart will also never be notified, which, depending on the event loop/reactor/executor
implementation, may cause a deadlock.
Implementations§
Source§impl<S: Stream> FieldData<S>
impl<S: Stream> FieldData<S>
Sourcepub fn read_text(self) -> ReadTextField<S>
pub fn read_text(self) -> ReadTextField<S>
Get a Future which attempts to read the field data to a string.
If a field is meant to be read as text, it will either have no content-type or
will have a content-type that starts with “text”; FieldHeaders::is_text() is
provided to help determine this.
A default length limit for the string, in bytes, is set to avoid potential DoS attacks from
attackers running the server out of memory. If an incoming chunk is expected to push the
string over this limit, an error is returned. The limit value can be inspected and changed
on ReadTextField if desired.
§Charset
For simplicity, the default UTF-8 character set is assumed, as defined in IETF RFC 7578 Section 5.1.2. If the field body cannot be decoded as UTF-8, an error is returned.
Decoding text in a different charset (except ASCII which
is compatible with UTF-8) is, currently, beyond the scope of this crate. However, as a
convention, web browsers will send multipart/form-data requests in the same
charset as that of the document (page or frame) containing the form, so if you only serve
ASCII/UTF-8 pages then you won’t have to worry too much about decoding strange charsets.
Trait Implementations§
Source§impl<S: Stream> Drop for FieldData<S>
Notifies a task waiting on the parent Multipart that another field is available.
impl<S: Stream> Drop for FieldData<S>
Notifies a task waiting on the parent Multipart that another field is available.
Source§impl<S: Stream> Stream for FieldData<S>
impl<S: Stream> Stream for FieldData<S>
Source§fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>
None if
the stream is finished. Read moreSource§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
Source§fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
Future. Read moreSource§fn filter<F>(self, f: F) -> Filter<Self, F>
fn filter<F>(self, f: F) -> Filter<Self, F>
Source§fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>
fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>
Source§fn then<F, U>(self, f: F) -> Then<Self, F, U>
fn then<F, U>(self, f: F) -> Then<Self, F, U>
f. Read moreSource§fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>
f. Read moreSource§fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>
fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>
f. Read moreSource§fn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
Source§fn concat2(self) -> Concat2<Self>
fn concat2(self) -> Concat2<Self>
Source§fn concat(self) -> Concat<Self>
fn concat(self) -> Concat<Self>
Stream::concat2 insteadSource§fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>
fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>
true. Read moreSource§fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>
fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>
true. Read moreSource§fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>
fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>
Source§fn from_err<E>(self) -> FromErr<Self, E>
fn from_err<E>(self) -> FromErr<Self, E>
From for
this stream’s Error, returning a new stream. Read moreSource§fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
amt items of the underlying stream. Read moreSource§fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
amt items of the underlying stream. Read moreSource§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll will never again be called once it has
finished. Read moreSource§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn buffered(self, amt: usize) -> Buffered<Self>
fn buffered(self, amt: usize) -> Buffered<Self>
Source§fn buffer_unordered(self, amt: usize) -> BufferUnordered<Self>
fn buffer_unordered(self, amt: usize) -> BufferUnordered<Self>
Source§fn merge<S>(self, other: S) -> Merge<Self, S>
fn merge<S>(self, other: S) -> Merge<Self, S>
select nowSource§fn zip<S>(self, other: S) -> Zip<Self, S>
fn zip<S>(self, other: S) -> Zip<Self, S>
Source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek method. Read more