flams_ontology/content/declarations/
morphisms.rs

1use crate::{
2    content::ModuleTrait, uris::{ContentURIRef, SymbolURI}, Checked, CheckingState, Resolvable
3};
4
5use super::{Declaration, DeclarationTrait, OpenDeclaration};
6
7#[derive(Debug)]
8pub struct Morphism<State:CheckingState> {
9    pub uri: SymbolURI,
10    pub domain: State::ModuleLike,
11    pub total: bool,
12    pub elements: State::Seq<OpenDeclaration<State>>,
13}
14impl Resolvable for Morphism<Checked> {
15    type From = SymbolURI;
16    fn id(&self) -> std::borrow::Cow<'_,Self::From> {
17        std::borrow::Cow::Borrowed(&self.uri)
18    }
19}
20impl super::private::Sealed for Morphism<Checked> {}
21impl DeclarationTrait for Morphism<Checked> {
22    #[inline]
23    fn from_declaration(decl: &Declaration) -> Option<&Self> {
24        match decl {
25            Declaration::Morphism(m) => Some(m),
26            _ => None,
27        }
28    }
29}
30impl ModuleTrait for Morphism<Checked> {
31    #[inline]
32    fn declarations(&self) -> &[Declaration] {
33        &self.elements
34    }
35    #[inline]
36    fn content_uri(&self) -> ContentURIRef {
37        ContentURIRef::Symbol(&self.uri)
38    }
39}
40crate::serde_impl!{
41    struct Morphism[uri,domain,total,elements]
42}