pub struct TempDryIceFile { /* private fields */ }Expand description
Implementations§
Source§impl TempDryIceFile
impl TempDryIceFile
Sourcepub fn new() -> Result<Self, DryIceError>
pub fn new() -> Result<Self, DryIceError>
Create a temporary dryice file in the system temporary directory.
§Errors
Returns an error if a temporary file cannot be created.
Sourcepub fn new_in<P: AsRef<Path>>(directory: P) -> Result<Self, DryIceError>
pub fn new_in<P: AsRef<Path>>(directory: P) -> Result<Self, DryIceError>
Create a temporary dryice file in directory.
The directory must already exist. The file is created with exclusive creation semantics to avoid reusing an existing path.
§Errors
Returns an error if the directory does not exist, if permissions prevent file creation, or if a unique temporary path cannot be created after repeated attempts.
Sourcepub fn open(&self) -> Result<File, DryIceError>
pub fn open(&self) -> Result<File, DryIceError>
Open the owned temporary file for reading and writing.
The returned File is a normal Rust file handle. It can be passed into
DryIceWriter, returned by writer.finish(),
rewound, and then passed into DryIceReader:
use std::io::{Seek, SeekFrom};
use dryice::{DryIceWriter, SeqRecord, TempDryIceFile};
let temp = TempDryIceFile::new()?;
let file = temp.open()?;
let mut writer = DryIceWriter::builder().inner(file).build();
let record = SeqRecord::new(b"r1".to_vec(), b"ACGT".to_vec(), b"!!!!".to_vec())?;
writer.write_record(&record)?;
let mut file = writer.finish()?;
file.seek(SeekFrom::Start(0))?;
temp.cleanup()?;§Errors
Returns an error if the temporary file cannot be opened.
Sourcepub fn cleanup(self) -> Result<(), DryIceError>
pub fn cleanup(self) -> Result<(), DryIceError>
Remove the temporary file now.
Missing files are treated as already cleaned up. If the file has already
been persisted, cleanup is a no-op because dryice no longer owns the
file lifecycle.
§Errors
Returns an error if removing the temporary file fails for reasons other than the file already being absent.
Sourcepub fn persist<P: AsRef<Path>>(
&mut self,
path: P,
) -> Result<PathBuf, DryIceError>
pub fn persist<P: AsRef<Path>>( &mut self, path: P, ) -> Result<PathBuf, DryIceError>
Move the temporary file into a caller-owned path.
After a successful persist, dryice no longer owns the file lifecycle
and will not remove the destination on drop. The destination must not
already exist.
§Errors
Returns an error if path already exists or if the temporary file cannot
be renamed to path.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TempDryIceFile
impl RefUnwindSafe for TempDryIceFile
impl Send for TempDryIceFile
impl Sync for TempDryIceFile
impl Unpin for TempDryIceFile
impl UnsafeUnpin for TempDryIceFile
impl UnwindSafe for TempDryIceFile
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
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>
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>
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