Struct ScriptCode

Source
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)>,
}
Expand description

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.

Implementations§

Source§

impl ScriptCode<'_>

Source

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

Returns all of the script codes in no guarenteed order.

Source

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

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

§Examples
use iso15924::ScriptCode;

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

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

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());
Source

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

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());
Source

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

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());
Source

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

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());
Source

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

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§

Source§

impl<'a> Clone for ScriptCode<'a>

Source§

fn clone(&self) -> ScriptCode<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ScriptCode<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Hash for ScriptCode<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> Ord for ScriptCode<'a>

Source§

fn cmp(&self, other: &ScriptCode<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq for ScriptCode<'a>

Source§

fn eq(&self, other: &ScriptCode<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd for ScriptCode<'a>

Source§

fn partial_cmp(&self, other: &ScriptCode<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Eq for ScriptCode<'a>

Source§

impl<'a> StructuralPartialEq for ScriptCode<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ScriptCode<'a>

§

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

§

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

§

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

§

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

§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.