pub struct PublicErrorView<'a> { /* private fields */ }Expand description
A borrowed public projection of one descriptor-validated error context.
This view exposes only the descriptor’s stable identity, fixed public
message, and descriptor-owned protocol projections. Descriptors with
Exposure::Public may additionally expose declared public context fields;
Exposure::Generic descriptors expose no dynamic fields. The view borrows
its inputs and performs no allocation after the ErrorContext has been
constructed.
use rocketmq_error::{ErrorContext, PublicErrorView, ROUTE_TOPIC_NOT_FOUND};
let context = ErrorContext::new();
let view = PublicErrorView::try_new(&ROUTE_TOPIC_NOT_FOUND, &context).unwrap();
let _ = view.context;Implementations§
Source§impl PublicErrorView<'static>
impl PublicErrorView<'static>
Sourcepub const fn descriptor_only(descriptor: &'static ErrorDescriptor) -> Self
pub const fn descriptor_only(descriptor: &'static ErrorDescriptor) -> Self
Creates a public view containing descriptor-owned data only.
This is the safe fallback when retained context fails descriptor validation. It preserves the original descriptor and performs no allocation.
Source§impl<'a> PublicErrorView<'a>
impl<'a> PublicErrorView<'a>
Sourcepub fn try_new(
descriptor: &'static ErrorDescriptor,
context: &'a ErrorContext,
) -> Result<Self, ViewContextViolation>
pub fn try_new( descriptor: &'static ErrorDescriptor, context: &'a ErrorContext, ) -> Result<Self, ViewContextViolation>
Validates context against descriptor and creates a public safe view.
Every retained context field must exactly match a schema declared by
descriptor. Missing fields are valid because descriptor schemas do
not currently define required values.
§Errors
Returns ViewContextViolation for the first retained context field
that is undeclared or has a different complete schema.
Sourcepub fn fields(&self) -> PublicFields<'a> ⓘ
pub fn fields(&self) -> PublicFields<'a> ⓘ
Iterates permitted public fields in descriptor declaration order.
Generic-exposure descriptors always return an empty iterator.
Sourcepub const fn projection(&self) -> ProjectionSpec
pub const fn projection(&self) -> ProjectionSpec
Returns descriptor-owned boundary projections.
Sourcepub const fn is_truncated(&self) -> bool
pub const fn is_truncated(&self) -> bool
Returns whether context construction normalized, discarded, or truncated a value.