1use std::{
3 borrow::Cow,
4 collections::HashMap,
5 ops::{Add, AddAssign},
6 path::PathBuf,
7};
8
9use bstr::BStr;
10use gix_features::threading::OwnShared;
11
12mod mutable;
13pub use mutable::{multi_value::MultiValueMut, section::SectionMut, value::ValueMut};
14
15pub mod init;
17
18mod access;
19mod impls;
20pub mod includes;
22mod meta;
23mod util;
24
25pub mod section;
27
28pub mod rename_section {
30 #[derive(Debug, thiserror::Error)]
32 #[allow(missing_docs)]
33 pub enum Error {
34 #[error(transparent)]
35 Lookup(#[from] crate::lookup::existing::Error),
36 #[error(transparent)]
37 Section(#[from] crate::parse::section::header::Error),
38 }
39}
40
41pub mod set_raw_value {
43 #[derive(Debug, thiserror::Error)]
45 #[allow(missing_docs)]
46 pub enum Error {
47 #[error(transparent)]
48 Header(#[from] crate::parse::section::header::Error),
49 #[error(transparent)]
50 ValueName(#[from] crate::parse::section::value_name::Error),
51 }
52}
53
54#[derive(Clone, Debug, PartialOrd, PartialEq, Ord, Eq, Hash)]
56pub struct Metadata {
57 pub path: Option<PathBuf>,
59 pub source: crate::Source,
61 pub level: u8,
65 pub trust: gix_sec::Trust,
67}
68
69#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
71pub struct Section<'a> {
72 header: crate::parse::section::Header<'a>,
73 body: section::Body<'a>,
74 meta: OwnShared<Metadata>,
75 id: SectionId,
76}
77
78#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone, Copy)]
80pub(crate) struct Index(pub(crate) usize);
81
82impl Add<Size> for Index {
83 type Output = Self;
84
85 fn add(self, rhs: Size) -> Self::Output {
86 Self(self.0 + rhs.0)
87 }
88}
89
90#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone, Copy)]
92pub(crate) struct Size(pub(crate) usize);
93
94impl AddAssign<usize> for Size {
95 fn add_assign(&mut self, rhs: usize) {
96 self.0 += rhs;
97 }
98}
99
100#[derive(PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord, Debug)]
111pub struct SectionId(pub(crate) usize);
112
113impl Default for SectionId {
114 fn default() -> Self {
115 SectionId(usize::MAX)
116 }
117}
118
119#[derive(PartialEq, Eq, Clone, Debug)]
125pub(crate) enum SectionBodyIdsLut<'a> {
126 Terminal(Vec<SectionId>),
128 NonTerminal(HashMap<Cow<'a, BStr>, Vec<SectionId>>),
130}
131#[cfg(test)]
132mod tests;
133mod write;