pub struct ErrorMetadata { /* private fields */ }Expand description
Typed structured metadata attached to an error context.
Unlike the ContextRecord trait (whose entries appear
in the error’s Display output), metadata stored here is not visible in
terminal output. It is intended for programmatic consumers: serialization,
snapshots, structured logs, and API responses.
Supports String, bool, i64, and u64 values via MetadataValue.
Implementations§
Source§impl ErrorMetadata
impl ErrorMetadata
pub fn new() -> Self
pub fn is_empty(&self) -> bool
pub fn as_map(&self) -> &BTreeMap<String, MetadataValue>
pub fn insert<K, V>(&mut self, key: K, value: V)
pub fn get(&self, key: &str) -> Option<&MetadataValue>
pub fn get_str(&self, key: &str) -> Option<&str>
pub fn iter(&self) -> impl Iterator<Item = (&String, &MetadataValue)>
Sourcepub fn merge_missing(&mut self, other: &ErrorMetadata)
pub fn merge_missing(&mut self, other: &ErrorMetadata)
Merge entries from other, keeping existing values.
For each key in other, the value is only inserted if the key does not
already exist in self. This implements an inner/first wins strategy
useful when merging layered metadata where earlier layers should take
priority.
See StructError::context_metadata()
for a usage example.
Trait Implementations§
Source§impl Clone for ErrorMetadata
impl Clone for ErrorMetadata
Source§fn clone(&self) -> ErrorMetadata
fn clone(&self) -> ErrorMetadata
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ErrorMetadata
impl Debug for ErrorMetadata
Source§impl Default for ErrorMetadata
impl Default for ErrorMetadata
Source§fn default() -> ErrorMetadata
fn default() -> ErrorMetadata
Returns the “default value” for a type. Read more
Source§impl PartialEq for ErrorMetadata
impl PartialEq for ErrorMetadata
impl Eq for ErrorMetadata
impl StructuralPartialEq for ErrorMetadata
Auto Trait Implementations§
impl Freeze for ErrorMetadata
impl RefUnwindSafe for ErrorMetadata
impl Send for ErrorMetadata
impl Sync for ErrorMetadata
impl Unpin for ErrorMetadata
impl UnsafeUnpin for ErrorMetadata
impl UnwindSafe for ErrorMetadata
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