pub struct InMemoryPackageSource { /* private fields */ }Expand description
A DOCX package stored entirely in memory.
Useful for:
- Unit and integration tests that don’t touch the file system
- Constructing minimal DOCX packages programmatically
- Verifying that higher-level code is decoupled from ZIP storage
§Example
use docx_templating::package::{InMemoryPackageSource, PackageSource};
let mut source = InMemoryPackageSource::new();
source.add_part("word/document.xml", b"<root/>".to_vec());
assert!(source.contains_part("word/document.xml").unwrap());
assert_eq!(
source.read_part("word/document.xml").unwrap().unwrap(),
b"<root/>"
);Implementations§
Source§impl InMemoryPackageSource
impl InMemoryPackageSource
Trait Implementations§
Source§impl Debug for InMemoryPackageSource
impl Debug for InMemoryPackageSource
Source§impl Default for InMemoryPackageSource
impl Default for InMemoryPackageSource
Source§impl PackageSource for InMemoryPackageSource
impl PackageSource for InMemoryPackageSource
Source§fn part_names(&self) -> Result<Vec<String>>
fn part_names(&self) -> Result<Vec<String>>
Return the names of all parts in this package. Read more
Source§fn contains_part(&self, name: &str) -> Result<bool>
fn contains_part(&self, name: &str) -> Result<bool>
Return
true if the named part exists in this package.Auto Trait Implementations§
impl Forget for InMemoryPackageSource
impl Freeze for InMemoryPackageSource
impl Move for InMemoryPackageSource
impl RefUnwindSafe for InMemoryPackageSource
impl Send for InMemoryPackageSource
impl Sync for InMemoryPackageSource
impl Unpin for InMemoryPackageSource
impl UnsafeUnpin for InMemoryPackageSource
impl UnwindSafe for InMemoryPackageSource
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