Skip to main content

Upload

Struct Upload 

Source
pub struct Upload<H> { /* private fields */ }
Expand description

A file a form submitted, with the caller’s handle for where its content was stored.

The parser does not keep an upload’s content: it reports the content to the caller as it arrives, and the caller stores it, such as in a temporary file, and gives the parser a handle of type H for it. The filename and media type are what the client declared, and must not be trusted: a filename can contain path separators, .., a tab, Unicode controls such as bidirectional overrides, and, decoded from filename* when ParameterRules::Mime apply, CR, LF, and NUL, and a media type need not describe the content. The parser never gives an upload with an empty filename, which means no file was chosen.

Implementations§

Source§

impl<H> Upload<H>

Source

pub fn new( untrusted_filename: impl Into<String>, untrusted_media_type: Option<MediaType>, size: u64, handle: H, ) -> Self

An upload as the parser would give it, such as for an application’s own tests of what it does with its declared struct.

Source

pub fn untrusted_filename(&self) -> &str

The filename the client declared, which the parser never gives empty, since an empty filename means no file was chosen. It can contain any character, as the type’s documentation describes, and must not be used as a local path, or written into another syntax, without checking or encoding it.

Source

pub fn untrusted_media_type(&self) -> Option<&MediaType>

The media type the client declared for the content, if any, which need not describe the content.

Source

pub fn size(&self) -> u64

The bytes of content the parser reported.

Source

pub fn handle(&self) -> &H

The caller’s handle for the stored content.

Source

pub fn into_handle(self) -> H

The handle, taken from the upload.

Trait Implementations§

Source§

impl<H> Debug for Upload<H>

Shows the size only, since the filename and media type are submitted content, and the handle may name them.

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<H> Forget for Upload<H>

§

impl<H> Freeze for Upload<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for Upload<H>
where H: RefUnwindSafe,

§

impl<H> Send for Upload<H>
where H: Send,

§

impl<H> Sync for Upload<H>
where H: Sync,

§

impl<H> Unpin for Upload<H>
where H: Unpin,

§

impl<H> UnsafeUnpin for Upload<H>
where H: UnsafeUnpin,

§

impl<H> UnwindSafe for Upload<H>
where H: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.