use std::rc::Rc;
use crate::option;
use std::collections::HashSet;
pub struct Descriptor {
name: Rc<String>,
aliases: HashSet<String>,
value_type: option::Type,
description: String,
}
impl Descriptor {
pub fn new(name: &str, value_type: option::Type, description: &str) -> Self {
Descriptor {
name: Rc::new(String::from(name)),
aliases: HashSet::new(),
value_type,
description: String::from(description),
}
}
pub fn name(&self) -> &String {
&self.name
}
pub fn take_name(&self) -> Rc<String> {
Rc::clone(&self.name)
}
pub fn value_type(&self) -> &option::Type {
&self.value_type
}
pub fn description(&self) -> &String {
&self.description
}
pub fn add_alias(mut self, alias: &str) -> Self {
self.aliases.insert(String::from(alias));
self
}
pub fn get_aliases(&self) -> &HashSet<String> {
&self.aliases
}
}