Trait TmpProc

Source
pub trait TmpProc {
    type Output;
    type Error;

    // Required methods
    fn update(&mut self, buf: &[u8]);
    fn finalize(
        &mut self,
        src: Option<&Path>,
    ) -> Result<(Self::Output, Option<PathBuf>), Self::Error>;
}
Expand description

Used to inspect contents as it is being fed to the temporary file and to finalize the temporary file when it is being persisted.

Required Associated Types§

Source

type Output

Application-defined data to be returned on successful finalization.

Source

type Error

Application-defined error type.

Required Methods§

Source

fn update(&mut self, buf: &[u8])

Called when a buffer has been written to the TmpFile storage.

Source

fn finalize( &mut self, src: Option<&Path>, ) -> Result<(Self::Output, Option<PathBuf>), Self::Error>

Called when the application has chosen to persist the file.

The role of this method is to:

  • Return its application-specific data of the associated type Output.
  • If src is Some() it means that the TmpFile is backed by a file, and the implementation of this method should return, as the second tuple member, Some(PathBuf), pointing out the target file that the temporary file should be persisted to. If src is None the temporary buffer is not stored in the file system and thus None should be returned instead.
§Errors

Returns application-specific errors.

Implementors§