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
impl BidiAlgorithm
Sourcepub fn new() -> Self
pub fn new() -> Self
Initializes a new instance of the BidiAlgorithm class.
Sourcepub fn resolved_levels(&self) -> &[i8]
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).
Sourcepub fn resolved_paragraph_embedding_level(&self) -> i32
pub fn resolved_paragraph_embedding_level(&self) -> i32
Gets the resolved paragraph embedding level
Sourcepub fn process(&mut self, data: &mut BidiData)
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.
Sourcepub 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]>,
)
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.
Sourcepub fn resolve_embedding_level(&self, data: &[BidiClass]) -> i8
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 lastprocesscall (or a prefix of it), because the isolate pairs found by that call are used to skip isolates.
Returns the resolved embedding level
Trait Implementations§
Source§impl Debug for BidiAlgorithm
impl Debug for BidiAlgorithm
Auto Trait Implementations§
impl Freeze for BidiAlgorithm
impl RefUnwindSafe for BidiAlgorithm
impl Send for BidiAlgorithm
impl Sync for BidiAlgorithm
impl Unpin for BidiAlgorithm
impl UnsafeUnpin for BidiAlgorithm
impl UnwindSafe for BidiAlgorithm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more