#[non_exhaustive]pub struct ExternalMessage<'a> {
pub source: ExternalMessageSource,
pub original: &'a str,
pub code: Option<&'a str>,
pub params: &'a [(String, String)],
}Expand description
A best-effort description of an external message.
The crate should pass as much stable metadata as it has (e.g. code and params for
validator) so the localizer can override specific messages without string matching.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.source: ExternalMessageSource§original: &'a strThe original text as provided by the external library.
code: Option<&'a str>Stable-ish identifier when available (e.g. validator error code).
params: &'a [(String, String)]Optional structured parameters when available.
Implementations§
Source§impl<'a> ExternalMessage<'a>
impl<'a> ExternalMessage<'a>
Sourcepub fn new(source: ExternalMessageSource, original: &'a str) -> Self
pub fn new(source: ExternalMessageSource, original: &'a str) -> Self
Construct an external message with no code or structured parameters.
Sourcepub fn with_params(self, params: &'a [(String, String)]) -> Self
pub fn with_params(self, params: &'a [(String, String)]) -> Self
Attach structured dependency-provided message parameters.
Trait Implementations§
Source§impl<'a> Clone for ExternalMessage<'a>
impl<'a> Clone for ExternalMessage<'a>
Source§fn clone(&self) -> ExternalMessage<'a>
fn clone(&self) -> ExternalMessage<'a>
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<'a> !RefUnwindSafe for ExternalMessage<'a>
impl<'a> !UnwindSafe for ExternalMessage<'a>
impl<'a> Freeze for ExternalMessage<'a>
impl<'a> Send for ExternalMessage<'a>
impl<'a> Sync for ExternalMessage<'a>
impl<'a> Unpin for ExternalMessage<'a>
impl<'a> UnsafeUnpin for ExternalMessage<'a>
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