pub struct Archive { /* private fields */ }
Expand description
An archive represents a tree of text files.
This type is used to read txtar files from disk and materialize the corresponding file layout.
Examples
use txtar::Archive;
let txt = "\
comment1
comment2
-- file1 --
File 1 text.
-- foo --
File 2 text.
-- empty --
-- noNL --
hello world";
let archive = Archive::from(txt);
archive.materialize("/tmp/somedir/").unwrap();
Implementations
sourceimpl Archive
impl Archive
sourcepub fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>
Serialize the archive as txtar into the I/O stream.
sourcepub fn materialize<P: AsRef<Path>>(
&self,
path: P
) -> Result<(), MaterializeError>
pub fn materialize<P: AsRef<Path>>(
&self,
path: P
) -> Result<(), MaterializeError>
Writes each file in this archive to the directory at the given path.
Errors
This function will error in the event a file would be written outside of the directory or if an existing file would be overwritten. Additionally, any errors caused by the underlying I/O operations will be propagated.
Trait Implementations
impl Eq for Archive
impl StructuralEq for Archive
impl StructuralPartialEq for Archive
Auto Trait Implementations
impl RefUnwindSafe for Archive
impl Send for Archive
impl Sync for Archive
impl Unpin for Archive
impl UnwindSafe for Archive
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more