unicode_bidi::level

Struct Level

source
pub struct Level(/* private fields */);
Expand description

Embedding Level

Embedding Levels are numbers between 0 and 126 (inclusive), where even values denote a left-to-right (LTR) direction and odd values a right-to-left (RTL) direction.

This struct maintains a valid status for level numbers, meaning that creating a new level, or mutating an existing level, with the value smaller than 0 (before conversion to u8) or larger than 125 results in an Error.

http://www.unicode.org/reports/tr9/#BD2

Implementations§

source§

impl Level

source

pub fn ltr() -> Level

New LTR level with smallest number value (0).

source

pub fn rtl() -> Level

New RTL level with smallest number value (1).

source

pub fn max_implicit_depth() -> u8

Maximum depth of the directional status stack during implicit resolutions.

source

pub fn max_explicit_depth() -> u8

Maximum depth of the directional status stack during explicit resolutions.

source

pub fn new(number: u8) -> Result<Level, Error>

Create new level, fail if number is larger than max_depth + 1.

source

pub fn new_explicit(number: u8) -> Result<Level, Error>

Create new level, fail if number is larger than max_depth.

source

pub fn number(&self) -> u8

The level number.

source

pub fn is_ltr(&self) -> bool

If this level is left-to-right.

source

pub fn is_rtl(&self) -> bool

If this level is right-to-left.

source

pub fn raise(&mut self, amount: u8) -> Result<(), Error>

Raise level by amount, fail if number is larger than max_depth + 1.

source

pub fn raise_explicit(&mut self, amount: u8) -> Result<(), Error>

Raise level by amount, fail if number is larger than max_depth.

source

pub fn lower(&mut self, amount: u8) -> Result<(), Error>

Lower level by amount, fail if number goes below zero.

source

pub fn new_explicit_next_ltr(&self) -> Result<Level, Error>

The next LTR (even) level greater than this, or fail if number is larger than max_depth.

source

pub fn new_explicit_next_rtl(&self) -> Result<Level, Error>

The next RTL (odd) level greater than this, or fail if number is larger than max_depth.

source

pub fn new_lowest_ge_rtl(&self) -> Result<Level, Error>

The lowest RTL (odd) level greater than or equal to this, or fail if number is larger than max_depth + 1.

source

pub fn bidi_class(&self) -> BidiClass

Generate a character type based on a level (as specified in steps X10 and N2).

source

pub fn vec(v: &[u8]) -> Vec<Level>

source

pub fn from_slice_unchecked(v: &[u8]) -> &[Level]

Converts a byte slice to a slice of Levels

Does not check if each level is within bounds (<= MAX_IMPLICIT_DEPTH), which is not a requirement for safety but is a requirement for correctness of the algorithm.

Trait Implementations§

source§

impl Clone for Level

source§

fn clone(&self) -> Level

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 Debug for Level

source§

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

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

impl From<Level> for u8

source§

fn from(val: Level) -> Self

Convert to the level number

source§

impl From<u8> for Level

source§

fn from(number: u8) -> Level

Create level by number

source§

impl Ord for Level

source§

fn cmp(&self, other: &Level) -> 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<&'a str> for Level

Used for matching levels in conformance tests

source§

fn eq(&self, s: &&'a str) -> 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 PartialEq<String> for Level

Used for matching levels in conformance tests

source§

fn eq(&self, s: &String) -> 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 PartialEq for Level

source§

fn eq(&self, other: &Level) -> 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 PartialOrd for Level

source§

fn partial_cmp(&self, other: &Level) -> 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 Copy for Level

source§

impl Eq for Level

source§

impl StructuralPartialEq for Level

Auto Trait Implementations§

§

impl Freeze for Level

§

impl RefUnwindSafe for Level

§

impl Send for Level

§

impl Sync for Level

§

impl Unpin for Level

§

impl UnwindSafe for Level

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.