summaryrefslogtreecommitdiffstats
path: root/intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs')
-rw-r--r--intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs b/intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs
new file mode 100644
index 0000000000..3a022990a6
--- /dev/null
+++ b/intl/l10n/rust/l10nregistry-rs/src/source/fetcher.rs
@@ -0,0 +1,30 @@
+use async_trait::async_trait;
+use fluent_fallback::types::ResourceId;
+use std::io;
+
+/// The users of [`FileSource`] implement this trait to provide loading of
+/// resources, returning the contents of a resource as a
+/// `String`. [`FileSource`] handles the conversion from string representation
+/// into `FluentResource`.
+///
+/// [`FileSource`]: source/struct.FileSource.html
+#[async_trait(?Send)]
+pub trait FileFetcher {
+ /// Return the `String` representation for `path`. This version is
+ /// blocking.
+ ///
+ /// See [`fetch`](#tymethod.fetch).
+ fn fetch_sync(&self, resource_id: &ResourceId) -> io::Result<String>;
+
+ /// Return the `String` representation for `path`.
+ ///
+ /// On success, returns `Poll::Ready(Ok(..))`.
+ ///
+ /// If no resource is available to be fetched, the method returns
+ /// `Poll::Pending` and arranges for the current task (via
+ /// `cx.waker().wake_by_ref()`) to receive a notification when the resource
+ /// is available.
+ ///
+ /// See [`fetch_sync`](#tymethod.fetch_sync)
+ async fn fetch(&self, path: &ResourceId) -> io::Result<String>;
+}