Skip to main content

compose_lens/model/
dns_search.rs

1//! Raw-preserving service DNS search-domain declarations.
2
3use crate::source::SourceSpan;
4
5use super::Located;
6
7/// The exact authored scalar or ordered-list form of service `dns_search`.
8#[derive(Debug, Clone, PartialEq, Eq)]
9#[non_exhaustive]
10pub enum DnsSearchForm {
11    /// One exact DNS search-domain string scalar.
12    Scalar(Located<String>),
13    /// An explicitly authored ordered list, including an explicit empty list.
14    List(Vec<Located<String>>),
15}
16
17/// An explicitly authored raw service `dns_search` value.
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct DnsSearch {
20    span: SourceSpan,
21    form: DnsSearchForm,
22}
23
24impl DnsSearch {
25    pub(crate) const fn new(span: SourceSpan, form: DnsSearchForm) -> Self {
26        Self { span, form }
27    }
28
29    /// Returns the exact span of the complete authored field value.
30    #[must_use]
31    pub const fn span(&self) -> SourceSpan {
32        self.span
33    }
34
35    /// Returns the authored scalar or ordered-list form without interpreting domain strings.
36    #[must_use]
37    pub const fn form(&self) -> &DnsSearchForm {
38        &self.form
39    }
40}