Struct message_locator::MessageLocator
source · [−]pub struct MessageLocator { /* private fields */ }
Implementations
sourceimpl MessageLocator
impl MessageLocator
sourcepub fn new(options: &MessageLocatorOptions) -> Self
pub fn new(options: &MessageLocatorOptions) -> Self
Constructs a MessageLocator
object.
sourcepub fn supported_locales(&self) -> HashSet<Language>
pub fn supported_locales(&self) -> HashSet<Language>
Returns a set of supported locale codes, reflecting
the ones that were specified when constructing the MessageLocator
.
sourcepub fn supports_locale(&self, arg: &Language) -> bool
pub fn supports_locale(&self, arg: &Language) -> bool
Returns true
if the locale is one of the supported locales
that were specified when constructing the MessageLocator
,
otherwise false
.
sourcepub fn current_locale(&self) -> Option<Language>
pub fn current_locale(&self) -> Option<Language>
Returns the currently loaded locale.
sourcepub fn current_locale_seq(&self) -> HashSet<Language>
pub fn current_locale_seq(&self) -> HashSet<Language>
Returns the currently loaded locale followed by its fallbacks or empty if no locale is loaded.
sourcepub async fn update_locale(&mut self, new_locale: Language) -> bool
pub async fn update_locale(&mut self, new_locale: Language) -> bool
Attempts to load the specified locale and its fallbacks.
If any resource fails to load, the method returns false
, otherwise true
.
sourcepub async fn load(&mut self, new_locale: Option<Language>) -> bool
pub async fn load(&mut self, new_locale: Option<Language>) -> bool
Attempts to load a locale and its fallbacks. If the locale argument is specified, it is loaded. Otherwise, if there is a default locale, it is loaded, and if not, the method panics.
If any resource fails to load, the method returns false
, otherwise true
.
sourcepub fn get_formatted<S: ToString>(
&self,
id: S,
options: Vec<&dyn MessageLocatorFormatArgument>
) -> String
pub fn get_formatted<S: ToString>(
&self,
id: S,
options: Vec<&dyn MessageLocatorFormatArgument>
) -> String
Retrieves message by identifier with formatting arguments.
Trait Implementations
sourceimpl Clone for MessageLocator
impl Clone for MessageLocator
Auto Trait Implementations
impl RefUnwindSafe for MessageLocator
impl Send for MessageLocator
impl Sync for MessageLocator
impl Unpin for MessageLocator
impl UnwindSafe for MessageLocator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more