Skip to main content

es_fluent/traits/fluent_message/
arguments.rs

1use crate::{
2    FluentValue,
3    registry::{StaticFluentArgumentName, StaticFluentMessageKey},
4};
5
6/// Generated Fluent arguments keyed by validated static argument names.
7#[derive(Clone, Debug, Default)]
8pub struct FluentArgs<'a> {
9    values: es_fluent_manager_core::FluentArgumentMap<'a>,
10}
11
12impl<'a> FluentArgs<'a> {
13    pub fn new() -> Self {
14        Self {
15            values: es_fluent_manager_core::FluentArgumentMap::default(),
16        }
17    }
18
19    pub fn insert(&mut self, name: StaticFluentArgumentName, value: FluentValue<'a>) {
20        self.values.insert(name, value);
21    }
22
23    pub fn as_raw(&self) -> &es_fluent_manager_core::FluentArgumentMap<'a> {
24        &self.values
25    }
26
27    pub fn is_empty(&self) -> bool {
28        self.values.is_empty()
29    }
30}
31
32/// Render-time lookup callback used by [`super::FluentMessage`] implementations.
33pub type FluentMessageLookup<'lookup> =
34    dyn for<'a> FnMut(StaticFluentMessageKey, Option<&'a FluentArgs<'a>>) -> String + 'lookup;
35
36/// Fallible render-time lookup callback supplied by [`super::FluentLocalizer`].
37pub type FluentLocalizerLookup<'lookup> = dyn for<'a> FnMut(StaticFluentMessageKey, Option<&'a FluentArgs<'a>>) -> Option<String>
38    + 'lookup;