1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use serde::de::Deserialize;
use std::fmt::Debug;
use std::fmt::Display;

use crate::metadata::format::AssetsOptions;

pub trait Value: for<'de> Deserialize<'de> + Clone + Debug + Display
	where Self: TryInto<AssetsOptions> {
	fn as_bool(&self) -> Option<bool>;
	fn as_str(&self) -> Option<&str>;
}


#[cfg(feature = "serde_json")]
impl Value for serde_json::Value {
	fn as_bool(&self) -> Option<bool> { serde_json::Value::as_bool(self) }
	fn as_str(&self) -> Option<&str> { serde_json::Value::as_str(self) }
}

#[cfg(feature = "toml")]
impl Value for toml::Value {
	fn as_bool(&self) -> Option<bool> { toml::Value::as_bool(self) }
	fn as_str(&self) -> Option<&str> { toml::Value::as_str(self) }
}