pub struct UserMessageFormatter;Expand description
User-facing message formatter.
This formatter simplifies technical errors and removes internal details.
use serde_saphyr::UserMessageFormatter;
let err = serde_saphyr::from_str::<String>("").unwrap_err();
let msg = err.render_with_formatter(&UserMessageFormatter);
assert_eq!(msg, "unexpected end of file at line 1, column 1");Implementations§
Source§impl UserMessageFormatter
impl UserMessageFormatter
Sourcepub fn with_localizer<'a>(
&self,
localizer: &'a dyn Localizer,
) -> UserMessageFormatterWithLocalizer<'a>
pub fn with_localizer<'a>( &self, localizer: &'a dyn Localizer, ) -> UserMessageFormatterWithLocalizer<'a>
Return a formatter that uses a custom Localizer.
This allows reusing the built-in user-facing messages while customizing wording
that is produced outside format_message (location suffixes, validation issue
composition, snippet labels, etc.).
Trait Implementations§
Source§impl Clone for UserMessageFormatter
impl Clone for UserMessageFormatter
Source§fn clone(&self) -> UserMessageFormatter
fn clone(&self) -> UserMessageFormatter
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 UserMessageFormatter
impl Debug for UserMessageFormatter
Source§impl Default for UserMessageFormatter
impl Default for UserMessageFormatter
Source§fn default() -> UserMessageFormatter
fn default() -> UserMessageFormatter
Returns the “default value” for a type. Read more
impl Copy for UserMessageFormatter
Auto Trait Implementations§
impl Freeze for UserMessageFormatter
impl RefUnwindSafe for UserMessageFormatter
impl Send for UserMessageFormatter
impl Sync for UserMessageFormatter
impl Unpin for UserMessageFormatter
impl UnsafeUnpin for UserMessageFormatter
impl UnwindSafe for UserMessageFormatter
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