1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use super::{Comment, ConfigBlockProperty, Identifier, Span, WithDocumentation, WithIdentifier, WithSpan};

/// A source block declaration.
#[derive(Debug, Clone)]
pub struct SourceConfig {
    /// Name of this source.
    pub name: Identifier,
    /// Top-level configuration properties for this source.
    pub properties: Vec<ConfigBlockProperty>,
    /// The comments for this source block.
    pub(crate) documentation: Option<Comment>,
    /// The location of this source block in the text representation.
    pub span: Span,
    /// The span of the inner contents.
    pub inner_span: Span,
}

impl WithIdentifier for SourceConfig {
    fn identifier(&self) -> &Identifier {
        &self.name
    }
}

impl WithSpan for SourceConfig {
    fn span(&self) -> Span {
        self.span
    }
}

impl WithDocumentation for SourceConfig {
    fn documentation(&self) -> Option<&str> {
        self.documentation.as_ref().map(|doc| doc.text.as_str())
    }
}