pub struct StampIndex { /* private fields */ }Implementations§
Source§impl StampIndex
impl StampIndex
Sourcepub fn open(path: PathBuf) -> Result<Self, LogError>
pub fn open(path: PathBuf) -> Result<Self, LogError>
Open or recover a .stampindex file at the given path. This method
reads the entire file into memory at startup. A missing file means
zero stamped ranges. So does an empty one: the first append creates
the file and then writes the header with its entry, so a crash between
the two leaves an empty file that holds nothing to misread.
§Errors
Returns LogError::MissingFormatVersion for the headerless layout a
broker before 1.0 wrote, LogError::UnsupportedFormatVersion for a
version other than STAMP_INDEX_VERSION, and an error when log I/O
fails or the entries are not a whole number of fixed-width records.
Sourcepub fn append(&mut self, entry: StampEntry) -> Result<(), LogError>
pub fn append(&mut self, entry: StampEntry) -> Result<(), LogError>
Append one stamped-range entry.
Entries need not arrive in offset order. Transactional ranges are added when their commit marker lands, and two interleaved transactions can commit in either order. The in-memory index is kept in canonical offset order, and ranges themselves must not overlap.
§Errors
Returns an error when appending to or syncing the file fails.
Sourcepub fn upsert(&mut self, entry: StampEntry) -> Result<(), LogError>
pub fn upsert(&mut self, entry: StampEntry) -> Result<(), LogError>
Insert a committed transactional range or replace the same exact range. Replacement upgrades append-time entries written by older brokers to the marker-time commit stamp.
§Errors
Returns an error for a partial overlap or when rewriting the sidecar fails.
Sourcepub fn truncate_from(&mut self, offset: Offset) -> Result<(), LogError>
pub fn truncate_from(&mut self, offset: Offset) -> Result<(), LogError>
Remove entries that cover offsets at or after offset and rewrite the
sidecar. Log truncation calls this after truncating the segment bytes.
§Errors
Returns an error when rewriting or syncing the sidecar fails.
Sourcepub fn remove_ranges(&mut self, ranges: &[OffsetRange]) -> Result<(), LogError>
pub fn remove_ranges(&mut self, ranges: &[OffsetRange]) -> Result<(), LogError>
Remove exact ranges, if present. Startup uses this to hide append-time transactional entries created by older brokers while the transaction is still open.
§Errors
Returns an error when rewriting or syncing the sidecar fails.
pub fn entries(&self) -> &[StampEntry]
Sourcepub fn stamp_for_offset(&self, offset: Offset) -> Option<u64>
pub fn stamp_for_offset(&self, offset: Offset) -> Option<u64>
The stamp of the entry whose inclusive [base_offset, last_offset]
range contains offset, or None when no entry covers it.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StampIndex
impl !UnwindSafe for StampIndex
impl Freeze for StampIndex
impl Send for StampIndex
impl Sync for StampIndex
impl Unpin for StampIndex
impl UnsafeUnpin for StampIndex
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<F> FnGhost for F
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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);