Skip to main content

finitio/schema/
ref.rs

1use crate::common::FilePosition;
2use crate::fio;
3
4use super::errors::ValidationError;
5use super::r#type::Type;
6use super::typemap::TypeMap;
7
8#[derive(Clone, Debug)]
9pub struct Ref {
10    pub target: Type,
11    pub position: FilePosition,
12}
13
14impl Ref {
15    pub(crate) fn from_fio(fref: &fio::RefType) -> Self {
16        let target = Type::from_fio_ref(fref);
17        Self {
18            target,
19            position: fref.position.clone(),
20        }
21    }
22
23    pub(crate) fn resolve(&mut self, type_map: &TypeMap) -> Result<(), ValidationError> {
24        self.target.resolve(type_map)?;
25        Ok(())
26    }
27}