Skip to main content

PublicErrorView

Struct PublicErrorView 

Source
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>

Source

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>

Source

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.

Source

pub const fn code(&self) -> ErrorCode

Returns the stable catalog code.

Source

pub const fn message(&self) -> &'static str

Returns the descriptor’s fixed public message.

Source

pub fn fields(&self) -> PublicFields<'a> ⓘ

Iterates permitted public fields in descriptor declaration order.

Generic-exposure descriptors always return an empty iterator.

Source

pub const fn projection(&self) -> ProjectionSpec

Returns descriptor-owned boundary projections.

Source

pub const fn is_truncated(&self) -> bool

Returns whether context construction normalized, discarded, or truncated a value.

Trait Implementations§

Source§

impl Debug for PublicErrorView<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PublicErrorView<'a>

§

impl<'a> RefUnwindSafe for PublicErrorView<'a>

§

impl<'a> Send for PublicErrorView<'a>

§

impl<'a> Sync for PublicErrorView<'a>

§

impl<'a> Unpin for PublicErrorView<'a>

§

impl<'a> UnsafeUnpin for PublicErrorView<'a>

§

impl<'a> UnwindSafe for PublicErrorView<'a>

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> 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, 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.