Skip to main content

ErrorContext

Struct ErrorContext 

Source
pub struct ErrorContext { /* private fields */ }
Expand description

Redaction-aware structured context for errors.

Context retains at most 16 unique catalog fields. The first value for a name wins and insertion order is preserved. Duplicate and over-capacity inserts are ignored and recorded by Self::is_truncated.

Implementations§

Source§

impl ErrorContext

Source

pub const fn new() -> Self

Creates an empty context.

Source

pub fn with_text(self, key: FieldKey<TextField>, value: impl AsRef<str>) -> Self

Adds bounded text under a catalog-owned text key.

Every Unicode control character is replaced with one space before the value is truncated at a UTF-8 boundary to the schema’s byte limit.

Source

pub fn with_i64(self, key: FieldKey<I64Field>, value: i64) -> Self

Adds a signed integer under a catalog-owned key.

Source

pub fn with_u64(self, key: FieldKey<U64Field>, value: u64) -> Self

Adds an unsigned integer under a catalog-owned key.

Source

pub fn with_bool(self, key: FieldKey<BoolField>, value: bool) -> Self

Adds a Boolean under a catalog-owned key.

Source

pub fn with_secret_presence(self, key: FieldKey<SecretPresenceField>) -> Self

Records the presence of secret-bearing input without accepting a value.

Source

pub fn public_fields(&self) -> impl Iterator<Item = &ErrorContextField>

Iterates fields approved for public projections in insertion order.

Source

pub fn is_empty(&self) -> bool

Returns whether the context contains no fields.

Source

pub fn len(&self) -> usize

Returns the number of retained fields.

Source

pub const fn is_truncated(&self) -> bool

Returns whether text, a duplicate field, or an over-capacity insert was truncated.

Trait Implementations§

Source§

impl Clone for ErrorContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorContext

Source§

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

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

impl Default for ErrorContext

Source§

fn default() -> Self

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

impl Display for ErrorContext

Source§

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

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

impl Eq for ErrorContext

Source§

impl PartialEq for ErrorContext

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ErrorContext

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.