pub struct FsDataProvider { /* private fields */ }
Expand description

A data provider that reads ICU4X data from a filesystem directory.

FsDataProvider implements BufferProvider, so it can be used in *_with_buffer_provider constructors across ICU4X.

Examples

use icu_locid::locale;
use icu_provider::hello_world::HelloWorldFormatter;
use icu_provider_fs::FsDataProvider;
use writeable::assert_writeable_eq;

// Create a DataProvider from data files stored in a filesystem directory:
let provider = FsDataProvider::try_new(concat!(
    env!("CARGO_MANIFEST_DIR"),
    "/tests/data/json",
))
.expect("Directory exists");

// Check that it works:
let formatter = HelloWorldFormatter::try_new_with_buffer_provider(
    &provider,
    &locale!("la").into(),
)
.expect("locale exists");

assert_writeable_eq!(formatter.format(), "Ave, munde");

Implementations

Create a new FsDataProvider given a filesystem directory.

Examples
use icu_provider_fs::FsDataProvider;

let provider = FsDataProvider::try_new("/path/to/data/directory")
    .expect_err("Specify a real directory in the line above");

Trait Implementations

Loads a DataPayload<BufferMarker> according to the key and request.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.