Skip to main content

BidiAlgorithm

Struct BidiAlgorithm 

Source
pub struct BidiAlgorithm { /* private fields */ }
Expand description

Implementation of Unicode bidirectional algorithm (UAX #9) https://unicode.org/reports/tr9/

The Bidi algorithm uses a number of memory arrays for resolved types, level information, bracket types, x9 removal maps and more…

This implementation of the BiDi algorithm has been designed to reduce memory pressure by re-using the same work buffers, so instances of this class should be re-used as much as possible.

The caller’s tables (original classes, paired bracket types and values, and the optional output levels) are borrowed for the duration of a process call instead of being stored as slices like upstream does.

Implementations§

Source§

impl BidiAlgorithm

Source

pub fn new() -> Self

Initializes a new instance of the BidiAlgorithm class.

Source

pub fn resolved_levels(&self) -> &[i8]

Gets the resolved levels.

Empty when the last process_classes call was given an output buffer (the levels were written there).

Source

pub fn resolved_paragraph_embedding_level(&self) -> i32

Gets the resolved paragraph embedding level

Source

pub fn process(&mut self, data: &mut BidiData)

Process data from a BiDiData instance

  • data - The BiDi Unicode data.

The classes of data are updated in place by rule N0 (nonspacing marks after resolved brackets take the bracket direction), as upstream.

Source

pub fn process_classes( &mut self, types: &mut [BidiClass], paired_bracket_types: &[BidiPairedBracketType], paired_bracket_values: &[i32], paragraph_embedding_level: i8, has_brackets: Option<bool>, has_embeddings: Option<bool>, has_isolates: Option<bool>, out_levels: Option<&mut [i8]>, )

Processes Bidi Data

Panics when out_levels is given and its length differs from the input data.

Source

pub fn resolve_embedding_level(&self, data: &[BidiClass]) -> i8

Resolve the paragraph embedding level if not explicitly passed by the caller. Also used by rule X5c for FSI isolating sequences.

  • data - The data to be evaluated; it must be the data of the last process call (or a prefix of it), because the isolate pairs found by that call are used to skip isolates.

Returns the resolved embedding level

Source

pub fn reset(&mut self)

Resets the bidi algorithm to a clean state.

Trait Implementations§

Source§

impl Debug for BidiAlgorithm

Source§

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

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

impl Default for BidiAlgorithm

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.