pub struct Journal {
pub path: PathBuf,
pub records: Vec<Record>,
}Expand description
An open journal: its records so far, appended to on disk as they come.
Fields§
§path: PathBuf§records: Vec<Record>Implementations§
Source§impl Journal
impl Journal
Sourcepub fn create(
dir: &Path,
started_at: i64,
retired_at: i64,
plan: ForkSlugPlan,
backups: Vec<BackupEntry>,
) -> Result<Journal, String>
pub fn create( dir: &Path, started_at: i64, retired_at: i64, plan: ForkSlugPlan, backups: Vec<BackupEntry>, ) -> Result<Journal, String>
A new journal in dir, starting with its header.
Sourcepub fn open(path: &Path) -> Result<Journal, String>
pub fn open(path: &Path) -> Result<Journal, String>
The journal at path. A last record cut short by a crash (no newline
after it, or one that doesn’t parse) was never acted on, since a record
is written before what it allows: it is discarded, and the file cut
back to the end of its last complete line, so the next record starts on
a line of its own. A complete record missing only its newline is kept.
Any other line that doesn’t parse is an error.
Sourcepub fn read(path: &Path) -> Result<Journal, String>
pub fn read(path: &Path) -> Result<Journal, String>
Journal::open without the repair: a torn last record is left out
but the file isn’t touched, for a reader that doesn’t hold the
migration lock while a run may be appending (the plan).
pub fn dir(&self) -> PathBuf
Sourcepub fn append(&mut self, record: Record) -> Result<(), String>
pub fn append(&mut self, record: Record) -> Result<(), String>
Append record on a line of its own and sync it to disk before
returning: the step it allows runs only once it is durable. A file
that doesn’t end in a newline (a record written without one) gets
one first, so two records never share a line.
pub fn header(&self) -> (i64, &ForkSlugPlan, &[BackupEntry])
Sourcepub fn intent(&self, uid: &str, step: Step) -> Option<&Value>
pub fn intent(&self, uid: &str, step: Step) -> Option<&Value>
The before-image recorded for step of uid, if its intent was.
pub fn done(&self, uid: &str, step: Step) -> bool
pub fn skipped(&self, uid: &str) -> Option<&str>
pub fn verified(&self, uid: &str) -> bool
pub fn undone(&self, uid: &str, step: Step) -> bool
pub fn finished(&self) -> Option<&[Fingerprint]>
pub fn rolled_back(&self) -> bool
Sourcepub fn intents(&self) -> Vec<(String, Step, Value)>
pub fn intents(&self) -> Vec<(String, Step, Value)>
Every intent, in the order it was recorded.
Sourcepub fn changes(&self, uid: &str) -> Vec<String>
pub fn changes(&self, uid: &str) -> Vec<String>
The changes each step recorded for uid, in order.
pub fn last_failure(&self) -> Option<String>
Auto Trait Implementations§
impl Freeze for Journal
impl RefUnwindSafe for Journal
impl Send for Journal
impl Sync for Journal
impl Unpin for Journal
impl UnsafeUnpin for Journal
impl UnwindSafe for Journal
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more