Skip to main content

compose_lens/model/
sysctl.rs

1//! Raw-preserving service `sysctls` declarations.
2
3use crate::source::SourceSpan;
4
5use super::{KeyValueEntry, Located};
6
7/// The exact authored mapping or list form of service `sysctls`.
8#[derive(Debug, Clone, PartialEq, Eq)]
9#[non_exhaustive]
10pub enum SysctlsForm {
11    /// Ordered mapping syntax with exact scalar value kinds and spelling retained.
12    Map(Vec<KeyValueEntry>),
13    /// Ordered list syntax with exact string items retained.
14    List(Vec<Located<String>>),
15}
16
17/// An explicitly authored service-level Compose `sysctls` value.
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct Sysctls {
20    span: SourceSpan,
21    form: SysctlsForm,
22}
23
24impl Sysctls {
25    pub(crate) const fn new(span: SourceSpan, form: SysctlsForm) -> Self {
26        Self { span, form }
27    }
28
29    /// Returns the exact span of the complete authored collection.
30    #[must_use]
31    pub const fn span(&self) -> SourceSpan {
32        self.span
33    }
34
35    /// Returns the authored mapping or list form without coercion or normalization.
36    #[must_use]
37    pub const fn form(&self) -> &SysctlsForm {
38        &self.form
39    }
40}