pub struct Journal { /* private fields */ }Expand description
The journal directory.
Implementations§
Source§impl Journal
impl Journal
Sourcepub fn lock(&self) -> Result<File>
pub fn lock(&self) -> Result<File>
Takes the journal’s lock for as long as the returned file is open: one agent per journal (another one’s recovery would stop this one’s tasks).
§Errors
An I/O error if the directory or lock file can’t be created, or WouldBlock if another
process holds the lock.
Sourcepub fn write(&self, attempt_id: &str, record: &JournalRecord) -> Result<()>
pub fn write(&self, attempt_id: &str, record: &JournalRecord) -> Result<()>
Records record for an attempt, replacing what was there; it is on disk when this
returns.
§Errors
An I/O error if the directory or file can’t be written, or InvalidInput for an
attempt ID that isn’t a safe file name.
Sourcepub fn write_many(&self, records: &[(&str, &JournalRecord)]) -> Result<()>
pub fn write_many(&self, records: &[(&str, &JournalRecord)]) -> Result<()>
Records several attempts’ records, as Self::write does each, with their files
written and flushed to disk side by side and the directory flushed once (M4B.5, B184):
a burst of results costs about one flush’s time, not two flushes each. On disk when this
returns, all of them; an error leaves those written before it.
§Errors
The first I/O error, or InvalidInput for an attempt ID that isn’t a safe file name
(then nothing is written).
Source§impl Journal
impl Journal
Sourcepub fn keep(&self, attempt_id: &str, kept: &KeptAttempt) -> Result<()>
pub fn keep(&self, attempt_id: &str, kept: &KeptAttempt) -> Result<()>
Keeps what an attempt’s cleanup needs to run after a restart; on disk when this returns.
§Errors
An I/O error if it can’t be written, or InvalidInput for an attempt ID that isn’t a
safe file name.
Sourcepub fn kept(&self, attempt_id: &str) -> Result<Option<KeptAttempt>>
pub fn kept(&self, attempt_id: &str) -> Result<Option<KeptAttempt>>
What was kept for an attempt’s cleanup; None if nothing was.
§Errors
An I/O error if it can’t be read, InvalidData if it doesn’t read as what was written,
or InvalidInput for an attempt ID that isn’t a safe file name.
Sourcepub fn add_handle(&self, attempt_id: &str, handle: &CleanupHandle) -> Result<()>
pub fn add_handle(&self, attempt_id: &str, handle: &CleanupHandle) -> Result<()>
Adds a handle to an attempt’s; on disk when this returns.
§Errors
An I/O error if it can’t be written, or InvalidInput for an attempt ID that isn’t a
safe file name.
Sourcepub fn handles(&self, attempt_id: &str) -> Result<Vec<CleanupHandle>>
pub fn handles(&self, attempt_id: &str) -> Result<Vec<CleanupHandle>>
An attempt’s handles, in registration order. A last line with no end, cut off by a crash, was never acknowledged to the task, and is left out.
§Errors
An I/O error if they can’t be read, InvalidData if a complete line doesn’t read, or
InvalidInput for an attempt ID that isn’t a safe file name.
Sourcepub fn remove(&self, attempt_id: &str) -> Result<()>
pub fn remove(&self, attempt_id: &str) -> Result<()>
Forgets an attempt; one that isn’t recorded is fine.
§Errors
An I/O error if the file can’t be removed, or InvalidInput for an attempt ID that
isn’t a safe file name.
Sourcepub fn recover(&self) -> Result<Vec<(String, JournalRecord)>>
pub fn recover(&self) -> Result<Vec<(String, JournalRecord)>>
Removes temporary files left by a crash and reads every attempt recorded, by ID; a file that doesn’t read is logged and removed (it was never acted on). Only for the agent holding the journal, before it starts writing.
§Errors
An I/O error if the directory can’t be read or created.
Trait Implementations§
impl Eq for Journal
impl StructuralPartialEq for Journal
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);