[][src]Struct iso15924::code::ScriptCode

pub struct ScriptCode<'a> {
    pub alias: Option<Cow<'a, str>>,
    pub code: Cow<'a, str>,
    pub date: ScriptDate,
    pub name: Cow<'a, str>,
    pub name_french: Cow<'a, str>,
    pub num: Cow<'a, str>,
    pub unicode_version: Option<(u8, u8)>,
}

Representation of each script code with all of the information provided by the standard.

Serde

This struct derives serde's Deserialize and Serialize if you enable the serde feature.

Fields

alias: Option<Cow<'a, str>>

The Property Value Alias as defined by unicode.org.

The definition is located here:

http://www.unicode.org/Public/UNIDATA/PropertyValueAliases.txt

code: Cow<'a, str>

4-character representation of the script code.

date: ScriptDate

The date of the introduction of the script to the standard.

name: Cow<'a, str>

The English name of the script code.

name_french: Cow<'a, str>

The French name of the script code.

num: Cow<'a, str>

Numeric 3-digit representation of the script code.

unicode_version: Option<(u8, u8)>

The version of the Unicode specification that the script was added in.

Methods

impl<'_> ScriptCode<'_>[src]

pub fn all() -> &'static [ScriptCode<'static>][src]

Returns all of the script codes in no guarenteed order.

pub fn by_alias(alias: impl AsRef<str>) -> Option<&'static ScriptCode<'static>>[src]

Retrieve a ScriptCode via its alias (Property Value Alias) value if one exists.

Examples

use iso15924::ScriptCode;

assert!(ScriptCode::by_alias("Ahom").is_some());

pub fn by_code(code: impl AsRef<str>) -> Option<&'static ScriptCode<'static>>[src]

Retrieve a ScriptCode via its code value if one exists.

Examples

use iso15924::ScriptCode;

assert!(ScriptCode::by_code("Blis").is_some());
assert!(ScriptCode::by_code("Abza").is_none());

pub fn by_date_range(
    from: Option<ScriptDate>,
    to: Option<ScriptDate>
) -> Vec<&'static ScriptCode<'static>>
[src]

Retrieve a Vec of ScriptCodes with ScriptDates that are within the range of the from and to given. The from and to are both optional, and can either be None or Some(ScriptDate) for variations of the range wanted.

Examples

Getting all ScriptCodes between 2005-01-01 and 2012-01-01:

use iso15924::{ScriptCode, ScriptDate};

let date_from = ScriptDate::new(2005, 01, 01);
let date_to = ScriptDate::new(2012, 01, 01);

let scripts = ScriptCode::by_date_range(Some(date_from), Some(date_to));

Retrieving all ScriptCodes after 2005-01-01:

use iso15924::{ScriptCode, ScriptDate};

let date_from = ScriptDate::new(2005, 01, 01);

let scripts = ScriptCode::by_date_range(Some(date_from), None);

Retrieving all ScriptCodes before 2012-01-01:

use iso15924::{ScriptCode, ScriptDate};

let date_to = ScriptDate::new(2012, 01, 01);

let scripts = ScriptCode::by_date_range(None, Some(date_to));

Consequentially, you can also retrieve no values:

use iso15924::ScriptCode;

assert_eq!(0, ScriptCode::by_date_range(None, None).len());

pub fn by_name(name: impl AsRef<str>) -> Option<&'static ScriptCode<'static>>[src]

Retrieve a ScriptCode via its name if it exists:

use iso15924::ScriptCode;

let script1 = ScriptCode::by_name("Adlam");
assert!(script1.is_some());

let script2 = ScriptCode::by_name("Aaaaa");
assert!(script2.is_none());

pub fn by_name_french(
    name: impl AsRef<str>
) -> Option<&'static ScriptCode<'static>>
[src]

Retrieve a ScriptCode via its name_french if it exists:

use iso15924::ScriptCode;

assert!(ScriptCode::by_name_french("arabe").is_some());

assert!(ScriptCode::by_name_french("aaaaa").is_none());

pub fn by_num(num: impl AsRef<str>) -> Option<&'static ScriptCode<'static>>[src]

Retrieve a ScriptCode via its num if it exists:

use iso15924::ScriptCode;

assert!(ScriptCode::by_num("070").is_some());
assert!(ScriptCode::by_num("000").is_none());

Trait Implementations

impl<'a> Clone for ScriptCode<'a>[src]

impl<'a> Eq for ScriptCode<'a>[src]

impl<'a> Ord for ScriptCode<'a>[src]

impl<'a> PartialEq<ScriptCode<'a>> for ScriptCode<'a>[src]

impl<'a> PartialOrd<ScriptCode<'a>> for ScriptCode<'a>[src]

impl<'a> Debug for ScriptCode<'a>[src]

impl<'a> Hash for ScriptCode<'a>[src]

Auto Trait Implementations

impl<'a> Send for ScriptCode<'a>

impl<'a> Sync for ScriptCode<'a>

impl<'a> Unpin for ScriptCode<'a>

impl<'a> UnwindSafe for ScriptCode<'a>

impl<'a> RefUnwindSafe for ScriptCode<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]