File

Struct File 

Source
pub struct File { /* private fields */ }
Expand description

A tempfile wrapper that includes the original filename

Implementations§

Source§

impl File

Source

pub fn into_inner(self) -> NamedTempFile

Source

pub fn original_file_name(&self) -> Option<&str>

The filename provided in the multipart/form-data request

Source

pub fn sanitized_file_name(&self) -> &str

The sanitized version of the original file name, or generated name if none provided

Source

pub fn persist<P: AsRef<Path>>(self, dir: P) -> Result<PathBuf, Error>

👎Deprecated since 0.5.4: Please use the ‘persist_in’ function instead

Persist the tempfile to an existing directory. Uses the sanitized file name and returns the full path

NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems. Also neither the file contents nor the containing directory are synchronized, so the update may not yet have reached the disk when persist returns.

Source

pub fn persist_in<P: AsRef<Path>>(self, dir: P) -> Result<PathBuf, Error>

Persist the tempfile to an existing directory. Uses the sanitized file name and returns the full path

NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems. Also neither the file contents nor the containing directory are synchronized, so the update may not yet have reached the disk when persist_in returns.

Source

pub fn persist_at<P: AsRef<Path>>(self, path: P) -> Result<File, Error>

Persist the tempfile at the specified file path.

NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems. Also neither the file contents nor the containing directory are synchronized, so the update may not yet have reached the disk when persist_at returns.

Source

pub fn new( file: NamedTempFile, original_file_name: Option<String>, mime_type: Option<&Mime>, ) -> Self

Source

pub fn new_with_file_name( file: NamedTempFile, original_file_name: String, ) -> Self

Source§

impl File

Source

pub fn persist_with_permissions<P: AsRef<Path>>( self, dir: P, mode: u32, ) -> Result<PathBuf, Error>

Persist the tempfile with specific permissions on Unix

NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems. Also neither the file contents nor the containing directory are synchronized, so the update may not yet have reached the disk when persist_with_permissions returns.

Source

pub fn persist_with_open_permissions<P: AsRef<Path>>( self, dir: P, ) -> Result<PathBuf, Error>

Persist the tempfile with 644 permissions on Unix

NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems. Also neither the file contents nor the containing directory are synchronized, so the update may not yet have reached the disk when persist_with_open_permissions returns.

Trait Implementations§

Source§

impl AsMut<NamedTempFile> for File

Source§

fn as_mut(&mut self) -> &mut NamedTempFile

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<NamedTempFile> for File

Source§

fn as_ref(&self) -> &NamedTempFile

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for File

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for File

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be 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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,