Skip to main content

json_gettext/common/
mod.rs

1mod json_get_text_builder;
2mod json_gettext;
3
4#[cfg(feature = "rocket")]
5mod rocket_feature;
6
7use std::collections::HashMap;
8
9pub use json_get_text_builder::*;
10#[cfg(feature = "rocket")]
11pub use rocket_feature::*;
12
13pub use self::json_gettext::*;
14use crate::JSONGetTextValue;
15
16/// The whole context: a map from each key (locale) to that key's texts.
17pub type Context<'a> = HashMap<crate::Key, HashMap<String, JSONGetTextValue<'a>>>;
18
19/// A value that can locate an entry in a context without allocating a new key.
20///
21/// The crate implements this for the enabled key backend, so you rarely implement it yourself.
22pub trait LookupKey {
23    fn lookup<'m, V>(&self, map: &'m HashMap<crate::Key, V>) -> Option<&'m V>;
24}
25
26/// A value that can be turned into a stored `Key`.
27///
28/// The crate implements this for the enabled key backend, so you rarely implement it yourself.
29pub trait IntoKey {
30    fn into_key(self) -> crate::Key;
31}