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§
Required Methods§
Sourcefn finalize(
&mut self,
src: Option<&Path>,
) -> Result<(Self::Output, Option<PathBuf>), Self::Error>
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
isSome()
it means that theTmpFile
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. Ifsrc
isNone
the temporary buffer is not stored in the file system and thusNone
should be returned instead.
§Errors
Returns application-specific errors.