pub struct JSONGetText<'a> { /* private fields */ }
Expand description
A wrapper for context and a default key. Keys are usually considered as locales.
Implementations§
Source§impl<'a> JSONGetText<'a>
impl<'a> JSONGetText<'a>
Sourcepub fn build<S: Into<String>>(default_key: S) -> JSONGetTextBuilder<'a>
pub fn build<S: Into<String>>(default_key: S) -> JSONGetTextBuilder<'a>
Create a new JSONGetTextBuilder
instance. You need to decide your default key at the stage.
Sourcepub fn contains_key<K: AsRef<str>>(&self, key: K) -> bool
pub fn contains_key<K: AsRef<str>>(&self, key: K) -> bool
Returns true
if the context contains a value for the specified key.
Sourcepub fn get_default_key(&self) -> &str
pub fn get_default_key(&self) -> &str
Get the default key.
Sourcepub fn get<K: AsRef<str>>(
&self,
key: K,
) -> &HashMap<String, JSONGetTextValue<'a>>
pub fn get<K: AsRef<str>>( &self, key: K, ) -> &HashMap<String, JSONGetTextValue<'a>>
Get a string map from context by a key.
Sourcepub fn get_text<T: AsRef<str>>(
&'a self,
text: T,
) -> Option<JSONGetTextValue<'a>>
pub fn get_text<T: AsRef<str>>( &'a self, text: T, ) -> Option<JSONGetTextValue<'a>>
Get text from context.
Sourcepub fn get_text_with_key<K: AsRef<str>, T: AsRef<str>>(
&'a self,
key: K,
text: T,
) -> Option<JSONGetTextValue<'a>>
pub fn get_text_with_key<K: AsRef<str>, T: AsRef<str>>( &'a self, key: K, text: T, ) -> Option<JSONGetTextValue<'a>>
Get text from context with a specific key.
Sourcepub fn get_multiple_text<'b, T: AsRef<str> + ?Sized>(
&self,
text_array: &[&'b T],
) -> Option<HashMap<&'b str, JSONGetTextValue<'_>>>
pub fn get_multiple_text<'b, T: AsRef<str> + ?Sized>( &self, text_array: &[&'b T], ) -> Option<HashMap<&'b str, JSONGetTextValue<'_>>>
Get multiple text from context. The output map is usually used for serialization.
Sourcepub fn get_multiple_text_with_key<'b, K: AsRef<str>, T: AsRef<str> + ?Sized>(
&'a self,
key: K,
text_array: &[&'b T],
) -> Option<HashMap<&'b str, JSONGetTextValue<'a>>>
pub fn get_multiple_text_with_key<'b, K: AsRef<str>, T: AsRef<str> + ?Sized>( &'a self, key: K, text_array: &[&'b T], ) -> Option<HashMap<&'b str, JSONGetTextValue<'a>>>
Get multiple text from context with a specific key. The output map is usually used for serialization.
Sourcepub fn get_filtered_text(
&'a self,
regex: &Regex,
) -> Option<HashMap<&'a str, JSONGetTextValue<'a>>>
pub fn get_filtered_text( &'a self, regex: &Regex, ) -> Option<HashMap<&'a str, JSONGetTextValue<'a>>>
Get filtered text from context by a Regex instance. The output map is usually used for serialization.
Sourcepub fn get_filtered_text_with_key<K: AsRef<str>>(
&'a self,
key: K,
regex: &Regex,
) -> Option<HashMap<&'a str, JSONGetTextValue<'a>>>
pub fn get_filtered_text_with_key<K: AsRef<str>>( &'a self, key: K, regex: &Regex, ) -> Option<HashMap<&'a str, JSONGetTextValue<'a>>>
Get filtered text from context with a specific key by a Regex instance. The output map is usually used for serialization.