Skip to main content

Ledger

Struct Ledger 

Source
pub struct Ledger {
    dir: PathBuf,
    pub(super) document: Document,
    state: LedgerState,
}

Fields§

§dir: PathBuf§document: Document§state: LedgerState

Implementations§

Source§

impl Ledger

Source

pub fn open(game_dir: impl AsRef<Path>) -> Ledger

Source

pub fn state(&self) -> LedgerState

Source

pub fn state_dir(&self) -> &Path

.pacenotes inside the game folder.

Source

pub fn put(&mut self, key: &str, entry: LedgerEntry) -> Result<()>

Source

pub fn mark_installed(&mut self, key: &str) -> Result<()>

Separate from put, so a write-ahead entry and a finished one cannot be confused.

Source

pub fn remove(&mut self, key: &str) -> Result<()>

Source

pub fn replace_all( &mut self, packages: BTreeMap<String, LedgerEntry>, ) -> Result<()>

What restoring a point does.

Source

pub fn save_snapshot(&self, path: &Path) -> Result<()>

The packages alone, as replace_all takes them back.

Source

pub fn read_snapshot(path: &Path) -> Option<BTreeMap<String, LedgerEntry>>

What save_snapshot wrote, or None when it is missing or unreadable.

Source

pub fn save(&mut self) -> Result<()>

After each package, as a temp file renamed over the old one, so a run that dies leaves a ledger that still describes the disk. Refuses to replace a ledger it could not read, which may record a newer build’s packages.

Source§

impl Ledger

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn packages(&self) -> &BTreeMap<String, LedgerEntry>

By game/directory/name.

Source

pub fn get(&self, key: &str) -> Option<&LedgerEntry>

Source

pub fn unfinished(&self) -> Vec<String>

Entries a dead run left mid-install, to deal with before planning anything.

Source

pub fn owners_of(&self, path: &str) -> Vec<&str>

Compared folded, since two packages spelling a shared path differently own one file.

Source

pub fn owns(&self, path: &str) -> bool

A file nothing owns was the user’s, and is backed up before it is overwritten.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.