fluent_fallback/
generator.rs

1use fluent_bundle::{FluentBundle, FluentError, FluentResource};
2use futures::Stream;
3use rustc_hash::FxHashSet;
4use std::borrow::Borrow;
5use unic_langid::LanguageIdentifier;
6
7use crate::types::ResourceId;
8
9pub type FluentBundleResult<R> = Result<FluentBundle<R>, (FluentBundle<R>, Vec<FluentError>)>;
10
11pub trait BundleIterator {
12    fn prefetch_sync(&mut self) {}
13}
14
15#[async_trait::async_trait(?Send)]
16pub trait BundleStream {
17    async fn prefetch_async(&mut self) {}
18}
19
20pub trait BundleGenerator {
21    type Resource: Borrow<FluentResource>;
22    type LocalesIter: Iterator<Item = LanguageIdentifier>;
23    type Iter: Iterator<Item = FluentBundleResult<Self::Resource>>;
24    type Stream: Stream<Item = FluentBundleResult<Self::Resource>>;
25
26    fn bundles_iter(
27        &self,
28        _locales: Self::LocalesIter,
29        _res_ids: FxHashSet<ResourceId>,
30    ) -> Self::Iter {
31        unimplemented!();
32    }
33
34    fn bundles_stream(
35        &self,
36        _locales: Self::LocalesIter,
37        _res_ids: FxHashSet<ResourceId>,
38    ) -> Self::Stream {
39        unimplemented!();
40    }
41}