Skip to main content

compose_lens/model/
dns_option.rs

1//! Raw-preserving service DNS resolver options.
2
3use crate::source::SourceSpan;
4
5use super::Located;
6
7/// An explicitly authored ordered service `dns_opt` sequence.
8///
9/// Omission is represented by the absence of this value; an empty `items` slice therefore means
10/// the author explicitly supplied an empty sequence.
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct DnsOptions {
13    span: SourceSpan,
14    items: Vec<Located<String>>,
15}
16
17impl DnsOptions {
18    pub(crate) const fn new(span: SourceSpan, items: Vec<Located<String>>) -> Self {
19        Self { span, items }
20    }
21
22    /// Returns the span of the complete authored sequence.
23    #[must_use]
24    pub const fn span(&self) -> SourceSpan {
25        self.span
26    }
27
28    /// Returns every valid authored option in order, including exact duplicates.
29    #[must_use]
30    pub fn items(&self) -> &[Located<String>] {
31        &self.items
32    }
33}