pub struct Predicates { /* private fields */ }Expand description
The compiled predicate set.
Implementations§
Source§impl Predicates
impl Predicates
Sourcepub fn from_args(args: &RestoreArgs) -> Result<Self, RestoreError>
pub fn from_args(args: &RestoreArgs) -> Result<Self, RestoreError>
Compile the bound flags into a predicate set.
§Errors
Returns RestoreError::InvalidArgument when a partition’s
--exclude-offset ranges, merged, cover every offset from 0 through
that partition’s --to-offset bound: nothing between 0 and the
bound can survive, so the bound keeps zero records for that partition.
That is the one flag combination this function can prove empties a
partition without reading the archive, because both windows are named
entirely by the flags. Two related cases are deliberately not
flagged here. A negative --to-offset, which would exclude a whole
partition outright, is already rejected by RestoreArgs’s own
parser and never reaches this function. A --exclude-key or
--exclude-header pattern that matches every possible byte string,
such as an empty pattern or .*, is not detected either: proving a
regex is universal is not a check this function attempts, a partial
heuristic would catch some universal patterns and not others, and
unlike an offset window, a key predicate never empties a partition on
its own anyway, because a keyless record still survives it.
Source§impl Predicates
impl Predicates
Sourcepub fn offset_bound(&self, partition: &PartitionRef) -> Option<Offset>
pub fn offset_bound(&self, partition: &PartitionRef) -> Option<Offset>
The highest offset the restore keeps in partition, when
--to-offset names it.
--to-timestamp gives no equivalent lookup here, because it is a
global bound that applies to every partition alike, while
--to-offset is named per partition. Turning a timestamp bound into
an offset a caller could look up the same way would need a batch’s
own timestamp, and the only place that reads one is
Self::decide_batch; there is no offset this method can hand back
for a timestamp bound without decoding a batch first.
Sourcepub fn batch_past_offset_bound(
&self,
partition: &PartitionRef,
batch_base: Offset,
) -> bool
pub fn batch_past_offset_bound( &self, partition: &PartitionRef, batch_base: Offset, ) -> bool
Whether this batch and every later ordered batch start past the partition’s inclusive offset bound.
Sourcepub fn decide_batch(
&self,
partition: &PartitionRef,
batch: &RecordBatchBorrowed<'_>,
) -> Result<BatchDecision, RestoreError>
pub fn decide_batch( &self, partition: &PartitionRef, batch: &RecordBatchBorrowed<'_>, ) -> Result<BatchDecision, RestoreError>
Decide the fate of one archived batch.
The caller applies Self::batch_past_offset_bound first and stops
walking the partition once a batch’s base offset is past it. A batch
that straddles the inclusive offset bound is still decoded here so only
its records at or below the bound survive.
§Errors
While evaluating an applicable record predicate, returns an integrity error if a record fails to parse, lies outside the batch’s declared offset range, or its absolute offset or timestamp cannot be represented.
Sourcepub fn decide_record(
&self,
partition: &PartitionRef,
offset: Offset,
timestamp_ms: i64,
producer_id: ProducerId,
record: &RecordBorrowed<'_>,
) -> RecordDecision
pub fn decide_record( &self, partition: &PartitionRef, offset: Offset, timestamp_ms: i64, producer_id: ProducerId, record: &RecordBorrowed<'_>, ) -> RecordDecision
Decide the fate of one record inside a batch that must be re-encoded.
The record is dropped when any predicate matches, OR-combined: its
absolute offset falls in an --exclude-offset range for
partition, producer_id is named by --exclude-producer-id,
record.key matches an --exclude-key pattern, or one of record’s
headers matches an --exclude-header NAME=REGEX pattern by name and
value. A record is also dropped when it is above the partition’s
inclusive --to-offset bound or at or after the global exclusive
--to-timestamp bound. A record with key: None never matches a key
pattern, and a header whose value is absent never matches a header
pattern; neither is treated as matching an empty string.
--exclude-key and --exclude-header match the raw bytes only when
those bytes are valid UTF-8. regex::Regex::is_match takes &str,
and a byte string an operator’s regex cannot even be checked against
must not silently match it merely because it fails to decode, so
invalid UTF-8 never matches.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Predicates
impl RefUnwindSafe for Predicates
impl Send for Predicates
impl Sync for Predicates
impl Unpin for Predicates
impl UnsafeUnpin for Predicates
impl UnwindSafe for Predicates
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> ⓘ
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> 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);