pub trait StatusTracker: Debug + Send {
// Required methods
fn logged_items(&self) -> &[LogItem];
fn add_non_error(&mut self, log_item: LogItem);
fn add_error<E>(&mut self, log_item: LogItem, err: E) -> Result<(), E>;
// Provided methods
fn append(&mut self, other: &impl StatusTracker) { ... }
fn filter_errors(&mut self) -> impl Iterator<Item = &LogItem> { ... }
fn has_status(&self, val: &str) -> bool { ... }
fn has_error<E: Debug>(&self, err: E) -> bool { ... }
fn push_ingredient_uri<S: Into<String>>(&mut self, _uri: S) { ... }
fn pop_ingredient_uri(&mut self) -> Option<String> { ... }
}
Expand description
A StatusTracker
is used in the validation logic of c2pa-rs and
related crates to control error-handling behavior and optionally
aggregate log messages as they are generated.
Required Methods§
Sourcefn logged_items(&self) -> &[LogItem]
fn logged_items(&self) -> &[LogItem]
Return the current list of validation log items.
Sourcefn add_non_error(&mut self, log_item: LogItem)
fn add_non_error(&mut self, log_item: LogItem)
Add a non-error LogItem
to this status tracker.
Primarily intended for use by LogItem::success()
or LogItem::informational()
.
Sourcefn add_error<E>(&mut self, log_item: LogItem, err: E) -> Result<(), E>
fn add_error<E>(&mut self, log_item: LogItem, err: E) -> Result<(), E>
Add an error-case LogItem
to this status tracker.
Some implementations are configured to stop immediately on errors. If
so, this function will return Err(err)
.
If the implementation is configured to aggregate all log
messages, this function returns Ok(())
.
Primarily intended for use by LogItem::failure()
.
Provided Methods§
Sourcefn append(&mut self, other: &impl StatusTracker)
fn append(&mut self, other: &impl StatusTracker)
Appends the contents of another StatusTracker
to this list of
validation log items.
Sourcefn filter_errors(&mut self) -> impl Iterator<Item = &LogItem>
fn filter_errors(&mut self) -> impl Iterator<Item = &LogItem>
Return the LogItem
s that have error conditions (err_val
is
populated).
Removes matching items from the list of log items.
Sourcefn has_status(&self, val: &str) -> bool
fn has_status(&self, val: &str) -> bool
Return true
if the validation log contains a specific C2PA status
code.
Sourcefn has_error<E: Debug>(&self, err: E) -> bool
fn has_error<E: Debug>(&self, err: E) -> bool
Return true
if the validation log contains a specific error.
Sourcefn push_ingredient_uri<S: Into<String>>(&mut self, _uri: S)
fn push_ingredient_uri<S: Into<String>>(&mut self, _uri: S)
Keeps track of the current ingredient URI, if any.
The current URI may be added to any log items that are created.
Sourcefn pop_ingredient_uri(&mut self) -> Option<String>
fn pop_ingredient_uri(&mut self) -> Option<String>
Removes the current ingredient URI, if any.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.