use crate::schema::data::EffectData;
use crate::schema::parse::Schema;
pub trait HasSchema {
type A: 'static;
type I: 'static;
type E: EffectData + 'static;
fn schema() -> Schema<Self::A, Self::I, Self::E>
where
Self: Sized;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::schema::parse::{Schema, i64};
struct OnlyInt;
impl HasSchema for OnlyInt {
type A = i64;
type I = i64;
type E = ();
fn schema() -> Schema<Self::A, Self::I, Self::E> {
i64::<()>()
}
}
#[test]
fn manual_impl_returns_schema() {
let s = OnlyInt::schema();
assert_eq!(s.decode(3_i64).unwrap(), 3);
}
}