pub struct SourceBundleWriter<W> where
    W: Seek + Write
{ /* private fields */ }
Expand description

Writer to create SourceBundles.

Writers can either create a new file or be created from an existing file. Then, use add_file to add files and finally call finish to flush the archive to the underlying writer.

Note that dropping the writer

let mut bundle = SourceBundleWriter::create("bundle.zip")?;

// Add file called "foo.txt"
let file = File::open("my_file.txt")?;
bundle.add_file("foo.txt", file, SourceFileInfo::default())?;

// Flush the bundle to disk
bundle.finish()?;

Implementations

Creates a bundle writer on the given file.

Returns whether the bundle contains any files.

Sets a meta data attribute of the bundle.

Attributes are flushed to the bundle when it is finished. Thus, they can be retrieved or changed at any time before flushing the writer.

If the attribute was set before, the prior value is returned.

Removes a meta data attribute of the bundle.

If the attribute was set, the last value is returned.

Returns the value of a meta data attribute.

Determines whether a file at the given path has been added already.

Adds a file and its info to the bundle.

Multiple files can be added at the same path. For the first duplicate, a counter will be appended to the file name. Any subsequent duplicate increases that counter. For example:

let mut bundle = SourceBundleWriter::create("bundle.zip")?;

// Add file at "foo.txt"
bundle.add_file("foo.txt", File::open("my_duplicate.txt")?, SourceFileInfo::default())?;
assert!(bundle.has_file("foo.txt"));

// Add duplicate at "foo.txt.1"
bundle.add_file("foo.txt", File::open("my_duplicate.txt")?, SourceFileInfo::default())?;
assert!(bundle.has_file("foo.txt.1"));

Returns Ok(true) if the file was successfully added, or Ok(false) if the file aready existed. Otherwise, an error is returned if writing the file fails.

Writes a single object into the bundle.

Returns Ok(true) if any source files were added to the bundle, or Ok(false) if no sources could be resolved. Otherwise, an error is returned if writing the bundle fails.

This finishes the source bundle and flushes the underlying writer.

Writes a single object into the bundle.

Returns Ok(true) if any source files were added to the bundle, or Ok(false) if no sources could be resolved. Otherwise, an error is returned if writing the bundle fails.

This finishes the source bundle and flushes the underlying writer.

Before a file is written a callback is invoked which can return false to skip a file.

Writes the manifest to the bundle and flushes the underlying file handle.

Create a bundle writer that writes its output to the given path.

If the file does not exist at the given path, it is created. If the file does exist, it is overwritten.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more

Causes self to use its Binary implementation when Debug-formatted. Read more

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted. Read more

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.