use crate::prelude::{
any::TypeId,
fmt::Debug,
};
use crate::{
interner::UntrackedSymbol,
meta_type::MetaType,
};
#[cfg(feature = "schema")]
use schemars::JsonSchema;
#[cfg(feature = "serde")]
use serde::Serialize;
#[cfg(feature = "schema")]
pub trait JsonSchemaMaybe: JsonSchema {}
#[cfg(not(feature = "schema"))]
pub trait JsonSchemaMaybe {}
pub trait Form {
type Type: PartialEq + Eq + PartialOrd + Ord + Clone + Debug + JsonSchemaMaybe;
type String: AsRef<str>
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Clone
+ Debug
+ JsonSchemaMaybe;
}
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)]
pub enum MetaForm {}
impl Form for MetaForm {
type Type = MetaType;
type String = &'static str;
}
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[cfg_attr(feature = "serde", derive(Serialize))]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)]
pub enum PortableForm {}
cfg_if::cfg_if! {
if #[cfg(any(feature = "std", feature = "decode"))] {
impl Form for PortableForm {
type Type = UntrackedSymbol<TypeId>;
type String = crate::prelude::string::String;
}
} else {
impl Form for PortableForm {
type Type = UntrackedSymbol<TypeId>;
type String = &'static str;
}
}
}
#[cfg(not(feature = "schema"))]
impl<T> JsonSchemaMaybe for T {}
#[cfg(feature = "schema")]
impl<T> JsonSchemaMaybe for T where T: JsonSchema {}