Struct LogItem

Source
pub struct LogItem {
    pub kind: LogKind,
    pub label: Cow<'static, str>,
    pub description: Cow<'static, str>,
    pub crate_name: Cow<'static, str>,
    pub crate_version: Cow<'static, str>,
    pub file: Cow<'static, str>,
    pub function: Cow<'static, str>,
    pub line: u32,
    pub err_val: Option<Cow<'static, str>>,
    pub validation_status: Option<Cow<'static, str>>,
    pub ingredient_uri: Option<Cow<'static, str>>,
}
Expand description

Detailed information about an error or other noteworthy condition.

Use the log_item macro to create a LogItem.

Fields§

§kind: LogKind

Kind of log item.

§label: Cow<'static, str>

JUBMF label of the item (if available), or other descriptive label

§description: Cow<'static, str>

Description of the error

§crate_name: Cow<'static, str>

Crate where error was detected

§crate_version: Cow<'static, str>

Version of the crate

§file: Cow<'static, str>

Source file where error was detected

§function: Cow<'static, str>

Function where error was detected

§line: u32

Source line number where error was detected

§err_val: Option<Cow<'static, str>>

Error code as string

§validation_status: Option<Cow<'static, str>>

C2PA validation status code

§ingredient_uri: Option<Cow<'static, str>>

Ingredient URI (for ingredient-related logs)

Implementations§

Source§

impl LogItem

Source

pub fn validation_status(self, status: &'static str) -> Self

Add a C2PA validation status code.

§Example
let log = log_item!("test1", "test item 1", "test func").validation_status("claim.missing");

assert_eq!(
    log,
    LogItem {
        kind: LogKind::Informational,
        label: Cow::Borrowed("test1"),
        description: Cow::Borrowed("test item 1"),
        crate_name: Cow::Borrowed(env!("CARGO_PKG_NAME")),
        crate_version: Cow::Borrowed(env!("CARGO_PKG_VERSION")),
        file: Cow::Borrowed(file!()),
        function: Cow::Borrowed("test func"),
        line: 7,
        validation_status: Some(Cow::Borrowed("claim.missing")),
        ..Default::default()
    }
);
Source

pub fn set_ingredient_uri<S: Into<String>>(self, uri: S) -> Self

Add an ingredient URI.

§Example
let log = log_item!("test1", "test item 1", "test func")
    .set_ingredient_uri("self#jumbf=/c2pa/contentauth:urn:uuid:bef41f24-13aa-4040-8efa-08e5e85c4a00/c2pa.assertions/c2pa.ingredient__1");
Source

pub fn success(self, tracker: &mut impl StatusTracker)

Set the log item kind to LogKind::Success and add it to the StatusTracker.

Source

pub fn informational(self, tracker: &mut impl StatusTracker)

Set the log item kind to LogKind::Informational and add it to the StatusTracker.

Source

pub fn failure<E: Debug>( self, tracker: &mut impl StatusTracker, err: E, ) -> Result<(), E>

Set the log item kind to LogKind::Failure and add it to the StatusTracker.

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 will return Ok(()).

Source

pub fn failure_no_throw<E: Debug>( self, tracker: &mut impl StatusTracker, err: E, )

Set the log item kind to LogKind::Failure and add it to the StatusTracker.

Does not return a Result and thus ignores the StatusTracker error-handling configuration.

Trait Implementations§

Source§

impl Clone for LogItem

Source§

fn clone(&self) -> LogItem

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LogItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LogItem

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for LogItem

Source§

fn eq(&self, other: &LogItem) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LogItem

Source§

impl StructuralPartialEq for LogItem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.