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 u8)

🔬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.