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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use std::{
borrow::Cow,
collections::HashMap,
ops::{Add, AddAssign},
path::PathBuf,
};
use bstr::BStr;
use git_features::threading::OwnShared;
mod mutable;
pub use mutable::{multi_value::MultiValueMut, section::SectionMut, value::ValueMut};
pub mod init;
mod access;
mod impls;
pub mod includes;
mod meta;
mod util;
pub mod section;
pub mod rename_section {
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error(transparent)]
Lookup(#[from] crate::lookup::existing::Error),
#[error(transparent)]
Section(#[from] crate::parse::section::header::Error),
}
}
#[derive(Clone, Debug, PartialOrd, PartialEq, Ord, Eq, Hash)]
pub struct Metadata {
pub path: Option<PathBuf>,
pub source: crate::Source,
pub level: u8,
pub trust: git_sec::Trust,
}
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct Section<'a> {
header: crate::parse::section::Header<'a>,
body: section::Body<'a>,
meta: OwnShared<Metadata>,
}
pub type MetadataFilter = dyn FnMut(&'_ Metadata) -> bool;
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone, Copy)]
pub(crate) struct Index(pub(crate) usize);
impl Add<Size> for Index {
type Output = Self;
fn add(self, rhs: Size) -> Self::Output {
Self(self.0 + rhs.0)
}
}
#[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Debug, Clone, Copy)]
pub(crate) struct Size(pub(crate) usize);
impl AddAssign<usize> for Size {
fn add_assign(&mut self, rhs: usize) {
self.0 += rhs;
}
}
#[derive(PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord, Debug)]
pub(crate) struct SectionId(pub(crate) usize);
#[derive(PartialEq, Eq, Clone, Debug)]
pub(crate) enum SectionBodyIdsLut<'a> {
Terminal(Vec<SectionId>),
NonTerminal(HashMap<Cow<'a, BStr>, Vec<SectionId>>),
}
#[cfg(test)]
mod tests;
mod write;