pub struct Text { /* private fields */ }Expand description
A locale-free, translatable message; the English source is the lookup key. Build
with the t!/tn!/tp! macros or the builders here. Serializes as a plain
string when it has no context/plural/args (a descriptor label stays plain on
disk), else as a full object (a flash message keeps its args across a round-trip).
No Display.
Implementations§
Source§impl Text
impl Text
Sourcepub fn new(source: impl Into<Cow<'static, str>>) -> Self
pub fn new(source: impl Into<Cow<'static, str>>) -> Self
A message from a static source string (the macro path).
Sourcepub fn dynamic(s: impl Into<String>) -> Self
pub fn dynamic(s: impl Into<String>) -> Self
A message from a runtime (non-literal) string: the escape hatch extraction ignores.
Sourcepub fn with_context(self, context: impl Into<Cow<'static, str>>) -> Self
pub fn with_context(self, context: impl Into<Cow<'static, str>>) -> Self
Disambiguates a homonym source (Open the verb vs the adjective). The
context is part of the lookup key, never shown.
Sourcepub fn with_plural(self, other: impl Into<Cow<'static, str>>, n: i64) -> Self
pub fn with_plural(self, other: impl Into<Cow<'static, str>>, n: i64) -> Self
Marks a plural message: other is the plural source form, n the count the
category is chosen from.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Text
impl<'de> Deserialize<'de> for Text
Source§fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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