pub struct ErrorContext {
pub context: String,
pub span: Option<String>,
pub previous: Option<Box<ErrorContext>>,
}Expand description
#6 修复:错误上下文链节点
构成 Context → Context → ... 的单向链表,每一层记录
context(操作描述)与 span(可选 tracing span 名称)。
Fields§
§context: String当前层上下文描述(如 “fetching user by id”)
span: Option<String>可选 tracing span 名(如 “user_service”)
previous: Option<Box<ErrorContext>>上一层上下文(None 表示链尾)
Implementations§
Source§impl ErrorContext
impl ErrorContext
Sourcepub fn with_previous(self, prev: ErrorContext) -> Self
pub fn with_previous(self, prev: ErrorContext) -> Self
附加上一层上下文(消费 self,返回新的链头)
Sourcepub fn iter(&self) -> impl Iterator<Item = &ErrorContext>
pub fn iter(&self) -> impl Iterator<Item = &ErrorContext>
遍历上下文链,从最外层到最内层
Sourcepub fn format_chain(&self) -> String
pub fn format_chain(&self) -> String
格式化为多行字符串(每行一个上下文层)
Trait Implementations§
Source§impl Clone for ErrorContext
impl Clone for ErrorContext
Source§fn clone(&self) -> ErrorContext
fn clone(&self) -> ErrorContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ErrorContext
impl RefUnwindSafe for ErrorContext
impl Send for ErrorContext
impl Sync for ErrorContext
impl Unpin for ErrorContext
impl UnsafeUnpin for ErrorContext
impl UnwindSafe for ErrorContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more