#[derive(Debug, Clone)]
pub struct ContainerAttributes {
pub description: Option<String>,
pub title: Option<String>,
pub examples: Vec<proc_macro2::TokenStream>,
pub serde_rename_all: Option<String>,
pub validate: Option<String>,
pub serde_tag: Option<String>,
pub serde_content: Option<String>,
pub serde_untagged: bool,
}
#[derive(Default)]
pub struct ContainerAttributesBuilder {
description: Option<String>,
title: Option<String>,
examples: Vec<proc_macro2::TokenStream>,
serde_rename_all: Option<String>,
validate: Option<String>,
serde_tag: Option<String>,
serde_content: Option<String>,
serde_untagged: bool,
}
impl ContainerAttributesBuilder {
pub fn description(mut self, desc: Option<String>) -> Self {
self.description = desc;
self
}
pub fn title(mut self, title: Option<String>) -> Self {
self.title = title;
self
}
pub fn examples(mut self, examples: Vec<proc_macro2::TokenStream>) -> Self {
self.examples = examples;
self
}
pub fn serde_rename_all(mut self, rename_all: Option<String>) -> Self {
self.serde_rename_all = rename_all;
self
}
pub fn validate(mut self, validate: Option<String>) -> Self {
self.validate = validate;
self
}
pub fn serde_tag(mut self, tag: Option<String>) -> Self {
self.serde_tag = tag;
self
}
pub fn serde_content(mut self, content: Option<String>) -> Self {
self.serde_content = content;
self
}
pub fn serde_untagged(mut self, untagged: bool) -> Self {
self.serde_untagged = untagged;
self
}
pub fn build(self) -> ContainerAttributes {
ContainerAttributes {
description: self.description,
title: self.title,
examples: self.examples,
serde_rename_all: self.serde_rename_all,
validate: self.validate,
serde_tag: self.serde_tag,
serde_content: self.serde_content,
serde_untagged: self.serde_untagged,
}
}
}
impl ContainerAttributes {
pub fn builder() -> ContainerAttributesBuilder {
ContainerAttributesBuilder::default()
}
#[cfg(test)]
#[allow(dead_code)]
pub fn is_empty(&self) -> bool {
self.description.is_none()
&& self.title.is_none()
&& self.examples.is_empty()
&& self.serde_rename_all.is_none()
&& self.validate.is_none()
&& self.serde_tag.is_none()
&& self.serde_content.is_none()
&& !self.serde_untagged
}
}