#[non_exhaustive]pub struct Upload { /* private fields */ }Expand description
A file posted in a multipart form.
Implementations§
Source§impl Upload
impl Upload
Sourcepub fn new(
file_name: impl Into<String>,
content_type: impl Into<String>,
bytes: impl Into<Bytes>,
) -> Self
pub fn new( file_name: impl Into<String>, content_type: impl Into<String>, bytes: impl Into<Bytes>, ) -> Self
A file as a browser would send it, e.g. in tests:
Upload::new("photo.png", "image/png", bytes).
Sourcepub fn file_name(&self) -> &str
pub fn file_name(&self) -> &str
The name the browser gave, e.g. coffee photo.JPG. Don’t trust it for paths.
Sourcepub fn content_type(&self) -> &str
pub fn content_type(&self) -> &str
The type the browser declared, e.g. image/jpeg. Don’t trust it for security.
Sourcepub fn extension(&self) -> Option<String>
pub fn extension(&self) -> Option<String>
The lowercase extension of the original name, if it is a plain one.
Sourcepub fn sniffed_type(&self) -> Option<&'static str>
pub fn sniffed_type(&self) -> Option<&'static str>
The type found in the file’s first bytes, for the formats Renox knows.
Sourcepub fn dimensions(&self) -> Option<(u32, u32)>
pub fn dimensions(&self) -> Option<(u32, u32)>
The image’s width and height in pixels, read from its header (PNG,
JPEG, GIF or WebP); None for anything else or a damaged header.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Upload
impl<'de> Deserialize<'de> for Upload
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl FieldValue for Upload
impl FieldValue for Upload
Auto Trait Implementations§
impl !Freeze for Upload
impl RefUnwindSafe for Upload
impl Send for Upload
impl Sync for Upload
impl Unpin for Upload
impl UnsafeUnpin for Upload
impl UnwindSafe for Upload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more