pub enum LocalizedString {
Plain(String),
Localized(HashMap<String, String>),
}Expand description
A localizable text value, matching the WIT localized-string variant.
Plain— a single string in the component’sdefault-language.Localized— a map of BCP 47 language tags to text.
Variants§
Plain(String)
A single string assumed to be in the component’s default-language.
Localized(HashMap<String, String>)
Language tag → text map. MUST include the component’s default-language.
Implementations§
Source§impl LocalizedString
impl LocalizedString
Sourcepub fn new(lang: impl Into<String>, text: impl Into<String>) -> Self
pub fn new(lang: impl Into<String>, text: impl Into<String>) -> Self
Create a localized string with a single language entry.
Sourcepub fn get(&self, lang: &str) -> Option<&str>
pub fn get(&self, lang: &str) -> Option<&str>
Look up text for a specific language tag.
For Plain, always returns the text (it is assumed to match any language).
For Localized, performs exact key lookup.
Trait Implementations§
Source§impl Clone for LocalizedString
impl Clone for LocalizedString
Source§fn clone(&self) -> LocalizedString
fn clone(&self) -> LocalizedString
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 LocalizedString
impl Debug for LocalizedString
Source§impl Default for LocalizedString
impl Default for LocalizedString
Source§impl From<&str> for LocalizedString
impl From<&str> for LocalizedString
Source§impl From<String> for LocalizedString
impl From<String> for LocalizedString
Auto Trait Implementations§
impl Freeze for LocalizedString
impl RefUnwindSafe for LocalizedString
impl Send for LocalizedString
impl Sync for LocalizedString
impl Unpin for LocalizedString
impl UnsafeUnpin for LocalizedString
impl UnwindSafe for LocalizedString
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