[−][src]Struct symbolic_debuginfo::sourcebundle::SourceBundleWriter
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
impl<W> SourceBundleWriter<W> where
W: Seek + Write,
[src]
W: Seek + Write,
pub fn start(writer: W) -> Result<Self, SourceBundleError>
[src]
Creates a bundle writer on the given file.
pub fn is_empty(&self) -> bool
[src]
Returns whether the bundle contains any files.
pub fn set_attribute<K, V>(&mut self, key: K, value: V) -> Option<String> where
K: Into<String>,
V: Into<String>,
[src]
K: Into<String>,
V: Into<String>,
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.
pub fn remove_attribute<K>(&mut self, key: K) -> Option<String> where
K: AsRef<str>,
[src]
K: AsRef<str>,
Removes a meta data attribute of the bundle.
If the attribute was set, the last value is returned.
pub fn attribute<K>(&mut self, key: K) -> Option<&str> where
K: AsRef<str>,
[src]
K: AsRef<str>,
Returns the value of a meta data attribute.
pub fn has_file<S>(&self, path: S) -> bool where
S: AsRef<str>,
[src]
S: AsRef<str>,
Determines whether a file at the given path has been added already.
pub fn add_file<S, R>(
&mut self,
path: S,
file: R,
info: SourceFileInfo
) -> Result<(), SourceBundleError> where
S: AsRef<str>,
R: Read,
[src]
&mut self,
path: S,
file: R,
info: SourceFileInfo
) -> Result<(), SourceBundleError> where
S: AsRef<str>,
R: Read,
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.
pub fn write_object<O>(
self,
object: &O,
object_name: &str
) -> Result<bool, SourceBundleError> where
O: ObjectLike,
O::Error: Fail,
[src]
self,
object: &O,
object_name: &str
) -> Result<bool, SourceBundleError> where
O: ObjectLike,
O::Error: Fail,
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.
pub fn write_object_with_filter<O, F>(
self,
object: &O,
object_name: &str,
filter: F
) -> Result<bool, SourceBundleError> where
O: ObjectLike,
O::Error: Fail,
F: FnMut(&FileEntry<'_>) -> bool,
[src]
self,
object: &O,
object_name: &str,
filter: F
) -> Result<bool, SourceBundleError> where
O: ObjectLike,
O::Error: Fail,
F: FnMut(&FileEntry<'_>) -> bool,
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.
pub fn finish(self) -> Result<(), SourceBundleError>
[src]
Writes the manifest to the bundle and flushes the underlying file handle.
impl SourceBundleWriter<BufWriter<File>>
[src]
pub fn create<P>(
path: P
) -> Result<SourceBundleWriter<BufWriter<File>>, SourceBundleError> where
P: AsRef<Path>,
[src]
path: P
) -> Result<SourceBundleWriter<BufWriter<File>>, SourceBundleError> where
P: AsRef<Path>,
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
impl<W> RefUnwindSafe for SourceBundleWriter<W> where
W: RefUnwindSafe,
W: RefUnwindSafe,
impl<W> Send for SourceBundleWriter<W> where
W: Send,
W: Send,
impl<W> Sync for SourceBundleWriter<W> where
W: Sync,
W: Sync,
impl<W> Unpin for SourceBundleWriter<W> where
W: Unpin,
W: Unpin,
impl<W> UnwindSafe for SourceBundleWriter<W> where
W: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,