use crate::datatype::{Attributes, DataType, Fields};
use super::StructBuilder;
use super::{NamedFields, UnnamedFields};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct Struct {
pub fields: Fields,
pub attributes: Attributes,
}
impl Struct {
pub fn unit() -> Self {
Self {
fields: Fields::Unit,
attributes: Default::default(),
}
}
pub fn named() -> StructBuilder<NamedFields> {
StructBuilder {
fields: NamedFields {
fields: Default::default(),
},
}
}
pub fn unnamed() -> StructBuilder<UnnamedFields> {
StructBuilder {
fields: UnnamedFields {
fields: Default::default(),
},
}
}
}
impl From<Struct> for DataType {
fn from(t: Struct) -> Self {
Self::Struct(t)
}
}