pub struct OutputStream {
pub header: Option<Vec<String>>,
/* private fields */
}Expand description
Represents an output file.
This struct is used to handle operations on an output file, such as writing to the file. This abstracts writing both plaintext and gzip-compressed files.
Fields§
§header: Option<Vec<String>>Implementations§
Source§impl OutputStream
impl OutputStream
Sourcepub fn new(filepath: impl Into<PathBuf>, header: Option<Vec<String>>) -> Self
pub fn new(filepath: impl Into<PathBuf>, header: Option<Vec<String>>) -> Self
Constructs a new OutputStream.
§Arguments
filepath- A string slice that holds the path to the file. If the file extension is.gz,OutputStreamwill automatically write gzip-compressed output.header- An optional vector of strings representing commented header lines to be written to the file.
Sourcepub fn new_stdout(header: Option<Vec<String>>) -> Self
pub fn new_stdout(header: Option<Vec<String>>) -> Self
Constructs a new OutputStream for standard output.
Sourcepub fn writer(&self) -> Result<Box<dyn Write>>
pub fn writer(&self) -> Result<Box<dyn Write>>
Opens the file and returns a writer.
If the file path ends with “.gz”, the file is treated as gzip-compressed, and the function will handle compression automatically. If a header is set, it will be written to the file.
§Returns
A result containing a Box<dyn Write> on success, or an io::Error on failure.
Auto Trait Implementations§
impl Freeze for OutputStream
impl RefUnwindSafe for OutputStream
impl Send for OutputStream
impl Sync for OutputStream
impl Unpin for OutputStream
impl UnwindSafe for OutputStream
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