use crate::errors;
use serde_json::{Map, Value};
pub mod command;
pub mod decode;
pub mod entry;
pub mod field;
pub mod scalar;
pub mod schema;
#[cfg(test)]
mod spec_test;
pub mod validate;
pub use command::{CliFieldHint, CliHints, HTTPFieldHint, HTTPHints, MCPFieldHint, MCPHints};
pub use entry::Entry;
pub use field::{FieldKind, FieldMeta, FieldSpec, HTTPField, MCPField};
pub use scalar::{format_duration as fmt_duration, parse_duration};
pub use schema::Schema;
pub type JsonMap = Map<String, Value>;
pub type HResult<T> = errors::Result<T>;
pub trait XyzField: Sized + 'static {
fn xyz_from_value(v: &Value) -> errors::Result<Self>;
fn xyz_zero() -> Self;
fn xyz_is_zero(&self) -> bool;
fn xyz_has_zero() -> bool {
true
}
fn xyz_rule_ok(&self, r: &validate::VRule) -> bool;
fn xyz_fmt(&self) -> String;
fn xyz_spec_of() -> FieldSpec;
fn xyz_validate_elem(&self, _meta: &FieldMeta) -> errors::Result<()> {
Ok(())
}
}
pub trait XyzSchema: Sized {
fn xyz_schema() -> Option<Schema>;
}
pub trait XyzArgs: XyzField + 'static {
fn xyz_spec() -> Vec<FieldSpec>;
fn xyz_meta() -> errors::Result<&'static [FieldMeta]>;
fn xyz_decode(map: &JsonMap, meta: &[FieldMeta]) -> errors::Result<Self>;
fn xyz_validate(&self, meta: &[FieldMeta]) -> errors::Result<()>;
fn xyz_type_check(idx: usize, meta: &[FieldMeta], v: &Value) -> errors::Result<()>;
}
pub fn spec_of<T: XyzField>() -> FieldSpec {
T::xyz_spec_of()
}