summaryrefslogtreecommitdiffstats
path: root/intl/icu_capi/cpp/docs/source/provider_ffi.rst
blob: fcd53586cdda2f338276178bab8b94c653f0bf6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
``provider::ffi``
=================

.. cpp:class:: ICU4XDataProvider

    An ICU4X data provider, capable of loading ICU4X data keys from some source.

    See the `Rust documentation for icu_provider <https://docs.rs/icu_provider/latest/icu_provider/index.html>`__ for more information.


    .. cpp:function:: static ICU4XDataProvider create_compiled()

        Constructs an :cpp:class:`ICU4XDataProvider` that uses compiled data.

        Requires the ``compiled_data`` feature.

        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.


    .. cpp:function:: static diplomat::result<ICU4XDataProvider, ICU4XError> create_fs(const std::string_view path)

        Constructs an ``FsDataProvider`` and returns it as an :cpp:class:`ICU4XDataProvider`. Requires the ``provider_fs`` Cargo feature. Not supported in WASM.

        See the `Rust documentation for FsDataProvider <https://docs.rs/icu_provider_fs/latest/icu_provider_fs/struct.FsDataProvider.html>`__ for more information.


    .. cpp:function:: static ICU4XDataProvider create_test()

        Deprecated

        Use ``create_compiled()``.


    .. cpp:function:: static diplomat::result<ICU4XDataProvider, ICU4XError> create_from_byte_slice(const diplomat::span<const uint8_t> blob)

        Constructs a ``BlobDataProvider`` and returns it as an :cpp:class:`ICU4XDataProvider`.

        See the `Rust documentation for BlobDataProvider <https://docs.rs/icu_provider_blob/latest/icu_provider_blob/struct.BlobDataProvider.html>`__ for more information.

        Lifetimes: ``blob`` must live for the duration of the program.


    .. cpp:function:: static ICU4XDataProvider create_empty()

        Constructs an empty :cpp:class:`ICU4XDataProvider`.

        See the `Rust documentation for EmptyDataProvider <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/empty/struct.EmptyDataProvider.html>`__ for more information.


    .. cpp:function:: diplomat::result<std::monostate, ICU4XError> fork_by_key(ICU4XDataProvider& other)

        Creates a provider that tries the current provider and then, if the current provider doesn't support the data key, another provider ``other``.

        This takes ownership of the ``other`` provider, leaving an empty provider in its place.

        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.

        See the `Rust documentation for ForkByKeyProvider <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/type.ForkByKeyProvider.html>`__ for more information.


    .. cpp:function:: diplomat::result<std::monostate, ICU4XError> fork_by_locale(ICU4XDataProvider& other)

        Same as ``fork_by_key`` but forks by locale instead of key.

        See the `Rust documentation for MissingLocalePredicate <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/predicates/struct.MissingLocalePredicate.html>`__ for more information.


    .. cpp:function:: diplomat::result<std::monostate, ICU4XError> enable_locale_fallback()

        Enables locale fallbacking for data requests made to this provider.

        Note that the test provider (from ``create_test``) already has fallbacking enabled.

        See the `Rust documentation for try_new <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.try_new>`__ for more information.

        Additional information: `1 <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html>`__


    .. cpp:function:: diplomat::result<std::monostate, ICU4XError> enable_locale_fallback_with(const ICU4XLocaleFallbacker& fallbacker)

        See the `Rust documentation for new_with_fallbacker <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.new_with_fallbacker>`__ for more information.

        Additional information: `1 <https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html>`__