blob: 10e7c2db42594dd757fe472b28859124c4be6bd1 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="This crate implements the Unicode Bidirectional Algorithm for display of mixed right-to-left and left-to-right text. It is written in safe Rust, compatible with the current stable release."><meta name="keywords" content="rust, rustlang, rust-lang, unicode_bidi"><title>unicode_bidi - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../unicode_bidi/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../unicode_bidi/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate unicode_bidi</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.3.13</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">unicode_bidi</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/unicode_bidi/lib.rs.html#10-1202">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This crate implements the <a href="http://www.unicode.org/reports/tr9/">Unicode Bidirectional Algorithm</a> for display of mixed
right-to-left and left-to-right text. It is written in safe Rust, compatible with the
current stable release.</p>
<h3 id="example"><a href="#example">Example</a></h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>unicode_bidi::BidiInfo;
<span class="comment">// This example text is defined using `concat!` because some browsers
// and text editors have trouble displaying bidi strings.
</span><span class="kw">let </span>text = <span class="macro">concat!</span>[
<span class="string">&quot;א&quot;</span>,
<span class="string">&quot;ב&quot;</span>,
<span class="string">&quot;ג&quot;</span>,
<span class="string">&quot;a&quot;</span>,
<span class="string">&quot;b&quot;</span>,
<span class="string">&quot;c&quot;</span>,
];
<span class="comment">// Resolve embedding levels within the text. Pass `None` to detect the
// paragraph level automatically.
</span><span class="kw">let </span>bidi_info = BidiInfo::new(<span class="kw-2">&amp;</span>text, <span class="prelude-val">None</span>);
<span class="comment">// This paragraph has embedding level 1 because its first strong character is RTL.
</span><span class="macro">assert_eq!</span>(bidi_info.paragraphs.len(), <span class="number">1</span>);
<span class="kw">let </span>para = <span class="kw-2">&amp;</span>bidi_info.paragraphs[<span class="number">0</span>];
<span class="macro">assert_eq!</span>(para.level.number(), <span class="number">1</span>);
<span class="macro">assert_eq!</span>(para.level.is_rtl(), <span class="bool-val">true</span>);
<span class="comment">// Re-ordering is done after wrapping each paragraph into a sequence of
// lines. For this example, I&#39;ll just use a single line that spans the
// entire paragraph.
</span><span class="kw">let </span>line = para.range.clone();
<span class="kw">let </span>display = bidi_info.reorder_line(para, line);
<span class="macro">assert_eq!</span>(display, <span class="macro">concat!</span>[
<span class="string">&quot;a&quot;</span>,
<span class="string">&quot;b&quot;</span>,
<span class="string">&quot;c&quot;</span>,
<span class="string">&quot;ג&quot;</span>,
<span class="string">&quot;ב&quot;</span>,
<span class="string">&quot;א&quot;</span>,
]);</code></pre></div>
<h2 id="features"><a href="#features">Features</a></h2>
<ul>
<li><code>std</code>: Enabled by default, but can be disabled to make <code>unicode_bidi</code>
<code>#![no_std]</code> + <code>alloc</code> compatible.</li>
<li><code>hardcoded-data</code>: Enabled by default. Includes hardcoded Unicode bidi data and more convenient APIs.</li>
<li><code>serde</code>: Adds [<code>serde::Serialize</code>] and [<code>serde::Deserialize</code>]
implementations to relevant types.</li>
</ul>
</div></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2><div class="item-table"><div class="item-row"><div class="item-left import-item" id="reexport.BidiDataSource"><code>pub use crate::data_source::<a class="trait" href="data_source/trait.BidiDataSource.html" title="trait unicode_bidi::data_source::BidiDataSource">BidiDataSource</a>;</code></div></div><div class="item-row"><div class="item-left import-item" id="reexport.Level"><code>pub use crate::level::<a class="struct" href="level/struct.Level.html" title="struct unicode_bidi::level::Level">Level</a>;</code></div></div><div class="item-row"><div class="item-left import-item" id="reexport.LTR_LEVEL"><code>pub use crate::level::<a class="constant" href="level/constant.LTR_LEVEL.html" title="constant unicode_bidi::level::LTR_LEVEL">LTR_LEVEL</a>;</code></div></div><div class="item-row"><div class="item-left import-item" id="reexport.RTL_LEVEL"><code>pub use crate::level::<a class="constant" href="level/constant.RTL_LEVEL.html" title="constant unicode_bidi::level::RTL_LEVEL">RTL_LEVEL</a>;</code></div></div></div><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="data_source/index.html" title="unicode_bidi::data_source mod">data_source</a></div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="deprecated/index.html" title="unicode_bidi::deprecated mod">deprecated</a></div><div class="item-right docblock-short">This module holds deprecated assets only.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="format_chars/index.html" title="unicode_bidi::format_chars mod">format_chars</a></div><div class="item-right docblock-short">Directional Formatting Characters</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="level/index.html" title="unicode_bidi::level mod">level</a></div><div class="item-right docblock-short">Bidi Embedding Level</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BidiInfo.html" title="unicode_bidi::BidiInfo struct">BidiInfo</a></div><div class="item-right docblock-short">Bidi information of the text.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.HardcodedBidiData.html" title="unicode_bidi::HardcodedBidiData struct">HardcodedBidiData</a></div><div class="item-right docblock-short">Hardcoded Bidi data that ships with the unicode-bidi crate.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.InitialInfo.html" title="unicode_bidi::InitialInfo struct">InitialInfo</a></div><div class="item-right docblock-short">Initial bidi information of the text.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Paragraph.html" title="unicode_bidi::Paragraph struct">Paragraph</a></div><div class="item-right docblock-short">Contains a reference of <code>BidiInfo</code> and one of its <code>paragraphs</code>.
And it supports all operation in the <code>Paragraph</code> that needs also its
<code>BidiInfo</code> such as <code>direction</code>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.ParagraphInfo.html" title="unicode_bidi::ParagraphInfo struct">ParagraphInfo</a></div><div class="item-right docblock-short">Bidi information about a single paragraph</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.BidiClass.html" title="unicode_bidi::BidiClass enum">BidiClass</a></div><div class="item-right docblock-short">Represents values of the Unicode character property
<a href="http://www.unicode.org/reports/tr44/#Bidi_Class"><code>Bidi_Class</code></a>, also
known as the <em>bidirectional character type</em>.</div></div><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Direction.html" title="unicode_bidi::Direction enum">Direction</a></div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.UNICODE_VERSION.html" title="unicode_bidi::UNICODE_VERSION constant">UNICODE_VERSION</a></div><div class="item-right docblock-short">The <a href="http://www.unicode.org/versions/">Unicode version</a> of data</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.bidi_class.html" title="unicode_bidi::bidi_class fn">bidi_class</a></div><div class="item-right docblock-short">Find the <code>BidiClass</code> of a single char.</div></div></div><h2 id="types" class="small-section-header"><a href="#types">Type Definitions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="type" href="type.LevelRun.html" title="unicode_bidi::LevelRun type">LevelRun</a></div><div class="item-right docblock-short">A maximal substring of characters with the same embedding level.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="unicode_bidi" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>