1pub use tilo_platform_caps::{Availability, availability, available};
4
5pub type Unsupported = tilo_platform_caps::Unsupported<Feature>;
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
8#[non_exhaustive]
9pub enum Feature {
10 Store,
11 OsKeychain,
14 Blocking,
15}
16
17pub(crate) const WEB_KEYCHAIN: &str =
18 "Browsers have no keychain; Tilo encrypts secrets with a key the browser keeps.";
19pub(crate) const WEB_BLOCKING: &str = "The browser's storage answers asynchronously.";
20
21impl tilo_platform_caps::Feature for Feature {
22 fn targets(self) -> [Availability; 3] {
26 use Availability::{Available, Unsupported};
27 match self {
28 Self::Store => [Available, Available, Available],
29 Self::OsKeychain => [Available, Available, Unsupported(WEB_KEYCHAIN)],
30 Self::Blocking => [Available, Available, Unsupported(WEB_BLOCKING)],
31 }
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38 use tilo_platform_caps::Feature as _;
39
40 #[test]
41 fn this_target_reads_its_own_column() {
42 assert_eq!(availability(Feature::Store), Availability::Available);
43 let web = Feature::Blocking.targets()[2];
44 assert_eq!(web, Availability::Unsupported(WEB_BLOCKING));
45 }
46}