use std::borrow::Cow;
use crate::{DataType, DeprecatedType};
#[derive(Debug, Clone, PartialEq)]
pub struct Field {
pub(crate) optional: bool,
pub(crate) flatten: bool,
pub(crate) deprecated: Option<DeprecatedType>,
pub(crate) docs: Cow<'static, str>,
pub(crate) ty: Option<DataType>,
}
impl Field {
pub fn optional(&self) -> bool {
self.optional
}
pub fn flatten(&self) -> bool {
self.flatten
}
pub fn deprecated(&self) -> Option<&DeprecatedType> {
self.deprecated.as_ref()
}
pub fn docs(&self) -> &Cow<'static, str> {
&self.docs
}
pub fn ty(&self) -> Option<&DataType> {
self.ty.as_ref()
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct UnnamedFields {
pub(crate) fields: Vec<Field>,
}
impl UnnamedFields {
pub fn fields(&self) -> &Vec<Field> {
&self.fields
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct NamedFields {
pub(crate) fields: Vec<(Cow<'static, str>, Field)>,
pub(crate) tag: Option<Cow<'static, str>>,
}
impl NamedFields {
pub fn fields(&self) -> &Vec<(Cow<'static, str>, Field)> {
&self.fields
}
pub fn tag(&self) -> &Option<Cow<'static, str>> {
&self.tag
}
}