multipart::server

Struct Multipart

Source
pub struct Multipart<R> { /* private fields */ }
Expand description

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

Implements Borrow<R> to allow access to the request body, if desired.

Implementations§

Source§

impl Multipart<()>

Source

pub fn from_request<R: HttpRequest>(req: R) -> Result<Multipart<R::Body>, R>

If the given HttpRequest is a multipart/form-data POST request, return the request body wrapped in the multipart reader. Otherwise, returns the original request.

Source§

impl<R: Read> Multipart<R>

Source

pub fn with_body<Bnd: Into<String>>(body: R, boundary: Bnd) -> Self

Construct a new Multipart with the given body reader and boundary.

§Note: boundary

This will prepend the requisite -- to the boundary string as documented in IETF RFC 1341, Section 7.2.1: “Multipart: the common syntax”. Simply pass the value of the boundary key from the Content-Type header in the request (or use Multipart::from_request(), if supported).

Source

pub fn read_entry(&mut self) -> Result<Option<MultipartField<&mut Self>>>

Read the next entry from this multipart request, returning a struct with the field’s name and data. See MultipartField for more info.

§Warning: Risk of Data Loss

If the previously returned entry had contents of type MultipartField::File, calling this again will discard any unread contents of that entry.

Source

pub fn into_entry(self) -> ReadEntryResult<Self>

Read the next entry from this multipart request, returning a struct with the field’s name and data. See MultipartField for more info.

Source

pub fn foreach_entry<F>(&mut self, foreach: F) -> Result<()>
where F: FnMut(MultipartField<&mut Self>),

Call f for each entry in the multipart request.

This is a substitute for Rust not supporting streaming iterators (where the return value from next() borrows the iterator for a bound lifetime).

Returns Ok(()) when all fields have been read, or the first error.

Source

pub fn save(&mut self) -> SaveBuilder<&mut Self>

Get a builder type for saving the files in this request to the filesystem.

See SaveBuilder for more information.

Trait Implementations§

Source§

impl<R> Borrow<R> for Multipart<R>

Source§

fn borrow(&self) -> &R

Immutably borrows from an owned value. Read more

Auto Trait Implementations§

§

impl<R> Freeze for Multipart<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Multipart<R>
where R: RefUnwindSafe,

§

impl<R> Send for Multipart<R>
where R: Send,

§

impl<R> Sync for Multipart<R>
where R: Sync,

§

impl<R> Unpin for Multipart<R>
where R: Unpin,

§

impl<R> UnwindSafe for Multipart<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ReadEntry for T
where T: PrivReadEntry,

Source§

fn read_entry(self) -> ReadEntryResult<Self>

Attempt to read the next entry in the multipart stream.
Source§

fn read_entry_mut(&mut self) -> ReadEntryResult<&mut Self>

Equivalent to read_entry() but takes &mut self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V