pub struct Project {
pub book: Book,
pub assets: Vec<Asset>,
pub meta: Meta,
}Expand description
A book with its images and file metadata: what a .kernsetzer holds.
Fields§
§book: Book§assets: Vec<Asset>In file order; ids are unique and valid (Asset::is_valid_id).
meta: MetaImplementations§
Source§impl Project
impl Project
pub fn new(book: Book, assets: Vec<Asset>) -> Self
pub fn asset(&self, id: &str) -> Option<&Asset>
Sourcepub fn read<R: Read + Seek>(reader: R) -> Result<Self, ProjectError>
pub fn read<R: Read + Seek>(reader: R) -> Result<Self, ProjectError>
Read a .kernsetzer archive. book.json is migrated to the current
format. A missing or unreadable meta.json is not an error (the
book is what matters); entries under assets/ whose names are not
valid ids (.DS_Store, sub-folders) and unknown entries are
skipped. Asset metadata is derived from the bytes.
Sourcepub fn write<W: Write + Seek>(&self, writer: W) -> Result<W, ProjectError>
pub fn write<W: Write + Seek>(&self, writer: W) -> Result<W, ProjectError>
Write the archive as is (meta.modified unchanged).
pub fn open(path: &Path) -> Result<Self, ProjectError>
Sourcepub fn save(&mut self, path: &Path) -> Result<(), ProjectError>
pub fn save(&mut self, path: &Path) -> Result<(), ProjectError>
Save to path (atomically), set meta.modified, and remove the
autosave sidecar: after a clean save there is nothing to recover.
Sourcepub fn autosave(&self, path: &Path) -> Result<(), ProjectError>
pub fn autosave(&self, path: &Path) -> Result<(), ProjectError>
Write the autosave sidecar for the project at path
(autosave_path); the project file itself is not touched.
Trait Implementations§
impl StructuralPartialEq for Project
Auto Trait Implementations§
impl Freeze for Project
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnsafeUnpin for Project
impl UnwindSafe for Project
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