3 config
::tree
::{keys, Index, Key, Section}
,
7 /// The `index.threads` key.
8 pub const THREADS
: IndexThreads
=
9 IndexThreads
::new_with_validate("threads", &config
::Tree
::INDEX
, validate
::IndexThreads
);
12 /// The `index.threads` key.
13 pub type IndexThreads
= keys
::Any
<validate
::IndexThreads
>;
21 config
::{key::GenericErrorWithValue, tree::index::IndexThreads}
,
25 /// Parse `value` into the amount of threads to use, with `1` being single-threaded, or `0` indicating
26 /// to select the amount of threads, with any other number being the specific amount of threads to use.
27 pub fn try_into_index_threads(
30 ) -> Result
<usize, config
::key
::GenericErrorWithValue
> {
31 gix_config
::Integer
::try_from(value
.as_ref())
33 .and_then(|i
| i
.to_decimal().and_then(|i
| i
.try_into().ok()))
35 gix_config
::Boolean
::try_from(value
.as_ref())
37 .map(|b
| if b
.0 { 0 }
else { 1 }
)
39 .ok_or_else(|| GenericErrorWithValue
::from_value(self, value
.into_owned()))
44 impl Section
for Index
{
45 fn name(&self) -> &str {
49 fn keys(&self) -> &[&dyn Key
] {
55 use crate::{bstr::BStr, config::tree::keys}
;
57 pub struct IndexThreads
;
58 impl keys
::Validate
for IndexThreads
{
59 fn validate(&self, value
: &BStr
) -> Result
<(), Box
<dyn std
::error
::Error
+ Send
+ Sync
+ '
static>> {
60 super::Index
::THREADS
.try_into_index_threads(value
.into())?
;