Skip to main content

trellis_core/
scope.rs

1use crate::ScopeId;
2
3/// Inspectable metadata for a graph scope.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct ScopeMeta {
6    id: ScopeId,
7    debug_name: String,
8    parent: Option<ScopeId>,
9    closed: bool,
10}
11
12impl ScopeMeta {
13    pub(crate) fn new(id: ScopeId, debug_name: impl Into<String>, parent: Option<ScopeId>) -> Self {
14        Self {
15            id,
16            debug_name: debug_name.into(),
17            parent,
18            closed: false,
19        }
20    }
21
22    /// Returns this scope's id.
23    pub fn id(&self) -> ScopeId {
24        self.id
25    }
26
27    /// Returns this scope's debug name.
28    pub fn debug_name(&self) -> &str {
29        &self.debug_name
30    }
31
32    /// Returns this scope's parent, if any.
33    pub fn parent(&self) -> Option<ScopeId> {
34        self.parent
35    }
36
37    /// Returns whether this scope has been marked closed.
38    pub fn is_closed(&self) -> bool {
39        self.closed
40    }
41
42    pub(crate) fn close(&mut self) {
43        self.closed = true;
44    }
45}