Files
GopherGate/target/doc/icu_provider/index.html
2026-02-26 12:00:21 -05:00

56 lines
17 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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="`icu_provider` is one of the `ICU4X` components."><title>icu_provider - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="icu_provider" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Crate icu_provider</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../icu_provider/index.html">icu_<wbr>provider</a><span class="version">2.1.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#dynamic-data-providers" title="Dynamic Data Providers">Dynamic Data Providers</a><ul><li><a href="#bufferprovider" title="BufferProvider">BufferProvider</a></li></ul></li><li><a href="#provider-adapters" title="Provider Adapters">Provider Adapters</a></li><li><a href="#testing-provider" title="Testing Provider">Testing Provider</a></li><li><a href="#types-and-lifetimes" title="Types and Lifetimes">Types and Lifetimes</a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>icu_<wbr>provider</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/icu_provider/lib.rs.html#5-231">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>icu_provider</code> is one of the <code>ICU4X</code> components.</p>
<p>Unicodes experience with ICU4Xs parent projects, ICU4C and ICU4J, led the team to realize
that data management is the most critical aspect of deploying internationalization, and that it requires
a high level of customization for the needs of the platform it is embedded in. As a result
ICU4X comes with a selection of providers that should allow for ICU4X to naturally fit into
different business and technological needs of customers.</p>
<p><code>icu_provider</code> defines traits and structs for transmitting data through the ICU4X locale
data pipeline. The primary trait is <a href="trait.DataProvider.html" title="trait icu_provider::DataProvider"><code>DataProvider</code></a>. It is parameterized by a
<a href="trait.DataMarker.html" title="trait icu_provider::DataMarker"><code>DataMarker</code></a>, which is the type-system-level data identifier. <a href="trait.DataProvider.html" title="trait icu_provider::DataProvider"><code>DataProvider</code></a> has a single method,
<a href="trait.DataProvider.html#tymethod.load" title="method icu_provider::DataProvider::load"><code>DataProvider::load</code></a>, which transforms a <a href="struct.DataRequest.html" title="struct icu_provider::DataRequest"><code>DataRequest</code></a> into a <a href="struct.DataResponse.html" title="struct icu_provider::DataResponse"><code>DataResponse</code></a>.</p>
<ul>
<li><a href="struct.DataRequest.html" title="struct icu_provider::DataRequest"><code>DataRequest</code></a> contains selectors to choose a specific variant of the marker, such as a locale.</li>
<li><a href="struct.DataResponse.html" title="struct icu_provider::DataResponse"><code>DataResponse</code></a> contains the data if the request was successful.</li>
</ul>
<p>The most common types required for this crate are included via the prelude:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>icu_provider::prelude::<span class="kw-2">*</span>;</code></pre></div><h3 id="dynamic-data-providers"><a class="doc-anchor" href="#dynamic-data-providers">§</a>Dynamic Data Providers</h3>
<p>If the type system cannot be leveraged to load data (such as when dynamically loading from I/O),
theres another form of the <a href="trait.DataProvider.html" title="trait icu_provider::DataProvider"><code>DataProvider</code></a>: <a href="trait.DynamicDataProvider.html" title="trait icu_provider::DynamicDataProvider"><code>DynamicDataProvider</code></a>. While <a href="trait.DataProvider.html" title="trait icu_provider::DataProvider"><code>DataProvider</code></a> is parametrized
on the type-system level by a <a href="trait.DataMarker.html" title="trait icu_provider::DataMarker"><code>DataMarker</code></a> (which are distinct types implementing this trait),
<a href="trait.DynamicDataProvider.html" title="trait icu_provider::DynamicDataProvider"><code>DynamicDataProvider</code></a>s are parametrized at runtime by a <a href="struct.DataMarkerInfo.html" title="struct icu_provider::DataMarkerInfo"><code>DataMarkerInfo</code></a> struct, which essentially is the runtime
representation of the <a href="trait.DataMarker.html" title="trait icu_provider::DataMarker"><code>DataMarker</code></a> type.</p>
<p>The <a href="trait.DynamicDataProvider.html" title="trait icu_provider::DynamicDataProvider"><code>DynamicDataProvider</code></a> is still type-level parametrized by the type that it loads, and there are two
implementations that should be called out</p>
<ul>
<li><a href="trait.DynamicDataProvider.html" title="trait icu_provider::DynamicDataProvider"><code>DynamicDataProvider&lt;BufferMarker&gt;</code></a>, a.k.a. <a href="buf/trait.BufferProvider.html" title="trait icu_provider::buf::BufferProvider"><code>BufferProvider</code></a> returns data as <code>[u8]</code> buffers.</li>
</ul>
<h4 id="bufferprovider"><a class="doc-anchor" href="#bufferprovider">§</a>BufferProvider</h4>
<p>These providers are able to return unstructured data typically represented as
[<code>serde</code>]-serialized buffers. Users can call <a href="buf::AsDeserializingBufferProvider::as_deserializing"><code>as_deserializing()</code></a> to get an object
implementing <a href="trait.DataProvider.html" title="trait icu_provider::DataProvider"><code>DataProvider</code></a> by invoking Serde Deserialize.</p>
<p>Examples of BufferProviders:</p>
<ul>
<li><a href="https://docs.rs/icu_provider_fs/latest/icu_provider_fs/struct.FsDataProvider.html"><code>FsDataProvider</code></a> reads individual buffers from the filesystem.</li>
<li><a href="https://docs.rs/icu_provider_blob/latest/icu_provider_blob/struct.BlobDataProvider.html"><code>BlobDataProvider</code></a> reads buffers from a large in-memory blob.</li>
</ul>
<h3 id="provider-adapters"><a class="doc-anchor" href="#provider-adapters">§</a>Provider Adapters</h3>
<p>ICU4X offers several built-in modules to combine providers in interesting ways.
These can be found in the <a href="https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/index.html"><code>icu_provider_adapters</code></a> crate.</p>
<h3 id="testing-provider"><a class="doc-anchor" href="#testing-provider">§</a>Testing Provider</h3>
<p>This crate also contains a concrete provider for demonstration purposes:</p>
<ul>
<li><a href="hello_world::HelloWorldProvider"><code>HelloWorldProvider</code></a> returns “hello world” strings in several languages.</li>
</ul>
<h3 id="types-and-lifetimes"><a class="doc-anchor" href="#types-and-lifetimes">§</a>Types and Lifetimes</h3>
<p>Types compatible with <a href="../yoke/yokeable/trait.Yokeable.html" title="trait yoke::yokeable::Yokeable"><code>Yokeable</code></a> can be passed through the data provider, so long as they are
associated with a marker type implementing <a href="trait.DynamicDataMarker.html" title="trait icu_provider::DynamicDataMarker"><code>DynamicDataMarker</code></a>.</p>
<p>Data structs should generally have one lifetime argument: <code>'data</code>. This lifetime allows data
structs to borrow zero-copy data.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="baked/index.html" title="mod icu_provider::baked">baked</a></dt><dd>This module contains scaffolding for baked providers, typically generated using
databake.</dd><dt><a class="mod" href="buf/index.html" title="mod icu_provider::buf">buf</a></dt><dd>Traits for data providers that produce opaque buffers.</dd><dt><a class="mod" href="constructors/index.html" title="mod icu_provider::constructors">constructors</a></dt><dd>📚 <em>This module documents ICU4X constructor signatures.</em></dd><dt><a class="mod" href="dynutil/index.html" title="mod icu_provider::dynutil">dynutil</a></dt><dd>Utilities for using trait objects with <code>DataPayload</code>.</dd><dt><a class="mod" href="marker/index.html" title="mod icu_provider::marker">marker</a></dt><dd>Additional <a href="trait.DataMarker.html" title="trait icu_provider::DataMarker"><code>DataMarker</code></a> helpers.</dd><dt><a class="mod" href="prelude/index.html" title="mod icu_provider::prelude">prelude</a></dt><dd>Core selection of APIs and structures for the ICU4X data provider.</dd><dt><a class="mod" href="ule/index.html" title="mod icu_provider::ule">ule</a></dt><dd>Traits that data provider implementations can use to optimize storage
by using <a href="../zerovec/ule/trait.VarULE.html" title="trait zerovec::ule::VarULE"><code>VarULE</code></a>.</dd></dl><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><dl class="item-table"><dt><a class="macro" href="macro._internal_noop_log.html" title="macro icu_provider::_internal_noop_log">_internal_<wbr>noop_<wbr>log</a></dt><dt><a class="macro" href="macro.data_marker.html" title="macro icu_provider::data_marker">data_<wbr>marker</a></dt><dd>Creates a data marker.</dd><dt><a class="macro" href="macro.data_struct.html" title="macro icu_provider::data_struct">data_<wbr>struct</a></dt><dd>Implements required traits on data structs, such as [<code>MaybeEncodeAsVarULE</code>].</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.AttributeParseError.html" title="struct icu_provider::AttributeParseError">Attribute<wbr>Parse<wbr>Error</a></dt><dd>Invalid character</dd><dt><a class="struct" href="struct.Cart.html" title="struct icu_provider::Cart">Cart</a></dt><dd>The type of the “cart” that is used by <a href="struct.DataPayload.html" title="struct icu_provider::DataPayload"><code>DataPayload</code></a>.</dd><dt><a class="struct" href="struct.DataError.html" title="struct icu_provider::DataError">Data<wbr>Error</a></dt><dd>The error type for ICU4X data provider operations.</dd><dt><a class="struct" href="struct.DataIdentifierBorrowed.html" title="struct icu_provider::DataIdentifierBorrowed">Data<wbr>Identifier<wbr>Borrowed</a></dt><dd>The borrowed version of a [<code>DataIdentifierCow</code>].</dd><dt><a class="struct" href="struct.DataLocale.html" title="struct icu_provider::DataLocale">Data<wbr>Locale</a></dt><dd>A locale type optimized for use in fallbacking and the ICU4X data pipeline.</dd><dt><a class="struct" href="struct.DataMarkerAttributes.html" title="struct icu_provider::DataMarkerAttributes">Data<wbr>Marker<wbr>Attributes</a></dt><dd>An additional key to identify data beyond a <a href="struct.DataLocale.html" title="struct icu_provider::DataLocale"><code>DataLocale</code></a>.</dd><dt><a class="struct" href="struct.DataMarkerInfo.html" title="struct icu_provider::DataMarkerInfo">Data<wbr>Marker<wbr>Info</a></dt><dd>Used for loading data from a dynamic ICU4X data provider.</dd><dt><a class="struct" href="struct.DataPayload.html" title="struct icu_provider::DataPayload">Data<wbr>Payload</a></dt><dd>A container for data payloads returned from a data provider.</dd><dt><a class="struct" href="struct.DataProviderWithMarker.html" title="struct icu_provider::DataProviderWithMarker">Data<wbr>Provider<wbr>With<wbr>Marker</a></dt><dd>A <a href="trait.DataProvider.html" title="trait icu_provider::DataProvider"><code>DataProvider</code></a> associated with a specific marker.</dd><dt><a class="struct" href="struct.DataRequest.html" title="struct icu_provider::DataRequest">Data<wbr>Request</a></dt><dd>The request type passed into all data provider implementations.</dd><dt><a class="struct" href="struct.DataRequestMetadata.html" title="struct icu_provider::DataRequestMetadata">Data<wbr>Request<wbr>Metadata</a></dt><dd>Metadata for data requests. This is currently empty, but it may be extended with options
for tuning locale fallback, buffer layout, and so forth.</dd><dt><a class="struct" href="struct.DataResponse.html" title="struct icu_provider::DataResponse">Data<wbr>Response</a></dt><dd>A response object containing an object as payload and metadata about it.</dd><dt><a class="struct" href="struct.DataResponseMetadata.html" title="struct icu_provider::DataResponseMetadata">Data<wbr>Response<wbr>Metadata</a></dt><dd>A response object containing metadata about the returned data.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.DataErrorKind.html" title="enum icu_provider::DataErrorKind">Data<wbr>Error<wbr>Kind</a></dt><dd>A list specifying general categories of data provider error.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.BoundDataProvider.html" title="trait icu_provider::BoundDataProvider">Bound<wbr>Data<wbr>Provider</a></dt><dd>A data provider that loads data for a specific data type.</dd><dt><a class="trait" href="trait.DataMarker.html" title="trait icu_provider::DataMarker">Data<wbr>Marker</a></dt><dd>A <a href="trait.DynamicDataMarker.html" title="trait icu_provider::DynamicDataMarker"><code>DynamicDataMarker</code></a> with a <a href="struct.DataMarkerInfo.html" title="struct icu_provider::DataMarkerInfo"><code>DataMarkerInfo</code></a> attached.</dd><dt><a class="trait" href="trait.DataProvider.html" title="trait icu_provider::DataProvider">Data<wbr>Provider</a></dt><dd>A data provider that loads data for a specific <a href="struct.DataMarkerInfo.html" title="struct icu_provider::DataMarkerInfo"><code>DataMarkerInfo</code></a>.</dd><dt><a class="trait" href="trait.DryDataProvider.html" title="trait icu_provider::DryDataProvider">DryData<wbr>Provider</a></dt><dd>A data provider that can determine whether it can load a particular data identifier,
potentially cheaper than actually performing the load.</dd><dt><a class="trait" href="trait.DynamicDataMarker.html" title="trait icu_provider::DynamicDataMarker">Dynamic<wbr>Data<wbr>Marker</a></dt><dd>Trait marker for data structs. All types delivered by the data provider must be associated with
something implementing this trait.</dd><dt><a class="trait" href="trait.DynamicDataProvider.html" title="trait icu_provider::DynamicDataProvider">Dynamic<wbr>Data<wbr>Provider</a></dt><dd>A data provider that loads data for a specific data type.</dd><dt><a class="trait" href="trait.DynamicDryDataProvider.html" title="trait icu_provider::DynamicDryDataProvider">Dynamic<wbr>DryData<wbr>Provider</a></dt><dd>A dynanmic data provider that can determine whether it can load a particular data identifier,
potentially cheaper than actually performing the load.</dd><dt><a class="trait" href="trait.ResultDataError.html" title="trait icu_provider::ResultDataError">Result<wbr>Data<wbr>Error</a></dt><dd>Extension trait for <code>Result&lt;T, DataError&gt;</code>.</dd></dl></section></div></main></body></html>