| 1 |
import { FFIError } from "./diplomat-runtime" |
| 2 |
import { ICU4XError } from "./ICU4XError"; |
| 3 |
import { ICU4XLocaleFallbacker } from "./ICU4XLocaleFallbacker"; |
| 4 |
|
| 5 |
/** |
| 6 |
|
| 7 |
* An ICU4X data provider, capable of loading ICU4X data keys from some source. |
| 8 |
|
| 9 |
* See the {@link https://docs.rs/icu_provider/latest/icu_provider/index.html Rust documentation for `icu_provider`} for more information. |
| 10 |
*/ |
| 11 |
export class ICU4XDataProvider { |
| 12 |
|
| 13 |
/** |
| 14 |
|
| 15 |
* Constructs an {@link ICU4XDataProvider `ICU4XDataProvider`} that uses compiled data. |
| 16 |
|
| 17 |
* Requires the `compiled_data` feature. |
| 18 |
|
| 19 |
* This provider cannot be modified or combined with other providers, so `enable_fallback`, `enabled_fallback_with`, `fork_by_locale`, and `fork_by_key` will return `Err`s. |
| 20 |
*/ |
| 21 |
static create_compiled(): ICU4XDataProvider; |
| 22 |
|
| 23 |
/** |
| 24 |
|
| 25 |
* Constructs an `FsDataProvider` and returns it as an {@link ICU4XDataProvider `ICU4XDataProvider`}. Requires the `provider_fs` Cargo feature. Not supported in WASM. |
| 26 |
|
| 27 |
* See the {@link https://docs.rs/icu_provider_fs/latest/icu_provider_fs/struct.FsDataProvider.html Rust documentation for `FsDataProvider`} for more information. |
| 28 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 29 |
*/ |
| 30 |
static create_fs(path: string): ICU4XDataProvider | never; |
| 31 |
|
| 32 |
/** |
| 33 |
|
| 34 |
* Deprecated |
| 35 |
|
| 36 |
* Use `create_compiled()`. |
| 37 |
*/ |
| 38 |
static create_test(): ICU4XDataProvider; |
| 39 |
|
| 40 |
/** |
| 41 |
|
| 42 |
* Constructs a `BlobDataProvider` and returns it as an {@link ICU4XDataProvider `ICU4XDataProvider`}. |
| 43 |
|
| 44 |
* See the {@link https://docs.rs/icu_provider_blob/latest/icu_provider_blob/struct.BlobDataProvider.html Rust documentation for `BlobDataProvider`} for more information. |
| 45 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 46 |
*/ |
| 47 |
static create_from_byte_slice(blob: Uint8Array): ICU4XDataProvider | never; |
| 48 |
|
| 49 |
/** |
| 50 |
|
| 51 |
* Constructs an empty {@link ICU4XDataProvider `ICU4XDataProvider`}. |
| 52 |
|
| 53 |
* See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/empty/struct.EmptyDataProvider.html Rust documentation for `EmptyDataProvider`} for more information. |
| 54 |
*/ |
| 55 |
static create_empty(): ICU4XDataProvider; |
| 56 |
|
| 57 |
/** |
| 58 |
|
| 59 |
* Creates a provider that tries the current provider and then, if the current provider doesn't support the data key, another provider `other`. |
| 60 |
|
| 61 |
* This takes ownership of the `other` provider, leaving an empty provider in its place. |
| 62 |
|
| 63 |
* The providers must be the same type (Any or Buffer). This condition is satisfied if both providers originate from the same constructor, such as `create_from_byte_slice` or `create_fs`. If the condition is not upheld, a runtime error occurs. |
| 64 |
|
| 65 |
* See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/type.ForkByKeyProvider.html Rust documentation for `ForkByKeyProvider`} for more information. |
| 66 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 67 |
*/ |
| 68 |
fork_by_key(other: ICU4XDataProvider): void | never; |
| 69 |
|
| 70 |
/** |
| 71 |
|
| 72 |
* Same as `fork_by_key` but forks by locale instead of key. |
| 73 |
|
| 74 |
* See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/predicates/struct.MissingLocalePredicate.html Rust documentation for `MissingLocalePredicate`} for more information. |
| 75 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 76 |
*/ |
| 77 |
fork_by_locale(other: ICU4XDataProvider): void | never; |
| 78 |
|
| 79 |
/** |
| 80 |
|
| 81 |
* Enables locale fallbacking for data requests made to this provider. |
| 82 |
|
| 83 |
* Note that the test provider (from `create_test`) already has fallbacking enabled. |
| 84 |
|
| 85 |
* See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.try_new Rust documentation for `try_new`} for more information. |
| 86 |
|
| 87 |
* Additional information: {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html 1} |
| 88 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 89 |
*/ |
| 90 |
enable_locale_fallback(): void | never; |
| 91 |
|
| 92 |
/** |
| 93 |
|
| 94 |
* See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.new_with_fallbacker Rust documentation for `new_with_fallbacker`} for more information. |
| 95 |
|
| 96 |
* Additional information: {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html 1} |
| 97 |
* @throws {@link FFIError}<{@link ICU4XError}> |
| 98 |
*/ |
| 99 |
enable_locale_fallback_with(fallbacker: ICU4XLocaleFallbacker): void | never; |
| 100 |
} |