LocaleData

Struct LocaleData 

Source
pub struct LocaleData {
    pub name: String,
    pub args: HashMap<String, LocaleValue>,
}
Expand description

Represents the localization data for a specific locale. This structure holds locale-specific information, such as the locale’s name and associated arguments or values used for localization.

Fields§

§name: String§args: HashMap<String, LocaleValue>

Implementations§

Source§

impl LocaleData

Source

pub fn new(name: &str) -> Self

Creates a new instance of the struct with the provided name.

§Parameters
  • name: A string slice that represents the name to associate with the instance.
§Returns

Returns a new instance of the struct, where the name field is initialized with the provided value and the args field is set to its default value.

§Example
use cjtoolkit_structured_validator::common::locale::LocaleData;
let instance = LocaleData::new("example");
Source

pub fn new_with_vec(name: &str, args: Vec<(String, LocaleValue)>) -> Self

Creates a new instance of the structure using a name and a vector of key-value pairs.

§Arguments
  • name - A string slice representing the name for the new instance.
  • args - A vector containing tuples, where each tuple consists of a String (key) and a LocaleValue (value). These key-value pairs will be used to initialize the args map of the structure.
§Returns

A new instance of the structure is populated with the provided name and args.

§Example
use cjtoolkit_structured_validator::common::locale::LocaleData;
use cjtoolkit_structured_validator::common::locale::LocaleValue;
let instance = LocaleData::new_with_vec("example_name", vec![
    ("key1".to_string(), LocaleValue::from("value1")),
    ("key2".to_string(), LocaleValue::from("value2")),
]);
assert_eq!(instance.name, "example_name");
assert!(instance.args.contains_key("key1"));

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,