1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::executable::VariableType;
use crate::{AsIter, ConstDirectives, ConstValue};

pub trait VariableDefinition {
    type VariableType: VariableType;
    type Directives: ConstDirectives;
    type Value: ConstValue;

    fn variable(&self) -> &str;
    fn r#type(&self) -> &Self::VariableType;
    fn directives(&self) -> &Self::Directives;
    fn default_value(&self) -> Option<&Self::Value>;

    fn is_required(&self) -> bool {
        self.default_value().is_none() && self.r#type().as_ref().is_required()
    }
}

pub trait VariableDefinitions: AsIter<Item = Self::VariableDefinition> {
    type VariableDefinition: VariableDefinition;
}