Skip to main content

bluejay_core/executable/
variable_definition.rs

1use crate::executable::VariableType;
2use crate::{AsIter, ConstDirectives, ConstValue};
3
4pub trait VariableDefinition {
5    type VariableType: VariableType;
6    type Directives: ConstDirectives;
7    type Value: ConstValue;
8
9    fn description(&self) -> Option<&str>;
10    fn variable(&self) -> &str;
11    fn r#type(&self) -> &Self::VariableType;
12    fn directives(&self) -> Option<&Self::Directives>;
13    fn default_value(&self) -> Option<&Self::Value>;
14
15    fn is_required(&self) -> bool {
16        self.default_value().is_none() && self.r#type().as_ref().is_required()
17    }
18}
19
20pub trait VariableDefinitions: AsIter<Item = Self::VariableDefinition> {
21    type VariableDefinition: VariableDefinition;
22}