pub struct Metadata { /* private fields */ }Expand description
Structured metadata attached to crate::AppError.
Internally backed by a deterministic BTreeMap keyed by 'static field
names. Use the helpers in field to build Field values without manual
enum construction.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn from_fields(fields: impl IntoIterator<Item = Field>) -> Self
pub fn from_fields(fields: impl IntoIterator<Item = Field>) -> Self
Build metadata from an iterator of Field values.
Sourcepub fn insert(&mut self, field: Field) -> Option<FieldValue>
pub fn insert(&mut self, field: Field) -> Option<FieldValue>
Insert or replace a field and return the previous value.
Sourcepub fn extend(&mut self, fields: impl IntoIterator<Item = Field>)
pub fn extend(&mut self, fields: impl IntoIterator<Item = Field>)
Extend metadata with additional fields.
Sourcepub fn get(&self, name: &'static str) -> Option<&FieldValue>
pub fn get(&self, name: &'static str) -> Option<&FieldValue>
Borrow a field value by name.
Sourcepub fn get_field(&self, name: &'static str) -> Option<&Field>
pub fn get_field(&self, name: &'static str) -> Option<&Field>
Borrow the full field entry by name.
Sourcepub fn set_redaction(&mut self, name: &'static str, redaction: FieldRedaction)
pub fn set_redaction(&mut self, name: &'static str, redaction: FieldRedaction)
Override the redaction policy for a specific field.
Sourcepub fn redaction(&self, name: &'static str) -> Option<FieldRedaction>
pub fn redaction(&self, name: &'static str) -> Option<FieldRedaction>
Retrieve the redaction policy for a field if present.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&'static str, &FieldValue)>
pub fn iter(&self) -> impl Iterator<Item = (&'static str, &FieldValue)>
Iterator over metadata fields in sorted order.
Sourcepub fn iter_with_redaction(
&self,
) -> impl Iterator<Item = (&'static str, &FieldValue, FieldRedaction)>
pub fn iter_with_redaction( &self, ) -> impl Iterator<Item = (&'static str, &FieldValue, FieldRedaction)>
Iterator over metadata entries including the redaction policy.
Trait Implementations§
Source§impl IntoIterator for Metadata
impl IntoIterator for Metadata
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnwindSafe for Metadata
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
Mutably borrows from an owned value. Read more