pub struct Any<T: Validate = All> {
pub name: &'static str,
pub section: &'static dyn Section,
pub subsection_requirement: Option<SubSectionRequirement>,
pub link: Option<Link>,
pub note: Option<Note>,
/* private fields */
}
Expand description
Implements a value without any constraints, i.e. a any value.
Fields§
§name: &'static str
The key of the value in the git configuration.
section: &'static dyn Section
The parent section of the key.
subsection_requirement: Option<SubSectionRequirement>
The subsection requirement to use.
link: Option<Link>
A link to other resources that might be eligible as value.
note: Option<Note>
A note about this key.
Implementations§
source§impl Any<FullNameRef>
impl Any<FullNameRef>
sourcepub fn try_into_fullrefname(
value: Cow<'_, BStr>
) -> Result<Cow<'_, FullNameRef>, Error>
pub fn try_into_fullrefname( value: Cow<'_, BStr> ) -> Result<Cow<'_, FullNameRef>, Error>
Return the validated full ref name from value
if it is valid.
source§impl Any<Workers>
impl Any<Workers>
sourcepub fn try_from_workers(
&'static self,
value: Result<i64, Error>
) -> Result<usize, Error>
pub fn try_from_workers( &'static self, value: Result<i64, Error> ) -> Result<usize, Error>
Return the amount of threads to use for checkout, with 0
meaning all available ones, after decoding our integer value from config
,
or None
if the value isn’t set which is typically interpreted as “as many threads as available”
source§impl Any<CheckRoundTripEncoding>
impl Any<CheckRoundTripEncoding>
sourcepub fn try_into_encodings(
&'static self,
value: Option<Cow<'_, BStr>>
) -> Result<Vec<&'static Encoding>, Error>
Available on crate feature attributes
only.
pub fn try_into_encodings( &'static self, value: Option<Cow<'_, BStr>> ) -> Result<Vec<&'static Encoding>, Error>
attributes
only.Convert value
into a list of encodings, which are either space or coma separated. Fail if an encoding is unknown.
If None
, the default is returned.
source§impl Any<Eol>
impl Any<Eol>
sourcepub fn try_into_eol(
&'static self,
value: Cow<'_, BStr>
) -> Result<Mode, GenericErrorWithValue>
Available on crate feature attributes
only.
pub fn try_into_eol( &'static self, value: Cow<'_, BStr> ) -> Result<Mode, GenericErrorWithValue>
attributes
only.Convert value
into the default end-of-line mode.
Deviation
git will allow any value and silently leaves it unset, we will fail if the value is not known.
source§impl Any<SafeCrlf>
impl Any<SafeCrlf>
sourcepub fn try_into_safecrlf(
&'static self,
value: Cow<'_, BStr>
) -> Result<CrlfRoundTripCheck, GenericErrorWithValue>
Available on crate feature attributes
only.
pub fn try_into_safecrlf( &'static self, value: Cow<'_, BStr> ) -> Result<CrlfRoundTripCheck, GenericErrorWithValue>
attributes
only.Convert value
into the safe-crlf enumeration, if possible.
source§impl Any<AutoCrlf>
impl Any<AutoCrlf>
sourcepub fn try_into_autocrlf(
&'static self,
value: Cow<'_, BStr>
) -> Result<AutoCrlf, GenericErrorWithValue>
Available on crate feature attributes
only.
pub fn try_into_autocrlf( &'static self, value: Cow<'_, BStr> ) -> Result<AutoCrlf, GenericErrorWithValue>
attributes
only.Convert value
into the safe-crlf enumeration, if possible.
source§impl Any<Disambiguate>
impl Any<Disambiguate>
sourcepub fn try_into_object_kind_hint(
&'static self,
value: Cow<'_, BStr>
) -> Result<Option<ObjectKindHint>, GenericErrorWithValue>
Available on crate feature revision
only.
pub fn try_into_object_kind_hint( &'static self, value: Cow<'_, BStr> ) -> Result<Option<ObjectKindHint>, GenericErrorWithValue>
revision
only.Convert a disambiguation marker into the respective enum.
source§impl Any<LogAllRefUpdates>
impl Any<LogAllRefUpdates>
sourcepub fn try_into_ref_updates(
&'static self,
value: Option<Result<bool, Error>>
) -> Result<Option<WriteReflog>, GenericErrorWithValue>
pub fn try_into_ref_updates( &'static self, value: Option<Result<bool, Error>> ) -> Result<Option<WriteReflog>, GenericErrorWithValue>
Returns the mode for ref-updates as parsed from value
. If value
is not a boolean, we try
to interpret the string value instead. For correctness, this two step process is necessary as
the interpretation of booleans in special in git-config
, i.e. we can’t just treat it as string.
source§impl Any<CheckStat>
impl Any<CheckStat>
sourcepub fn try_into_checkstat(
&'static self,
value: Cow<'_, BStr>
) -> Result<bool, GenericErrorWithValue>
pub fn try_into_checkstat( &'static self, value: Cow<'_, BStr> ) -> Result<bool, GenericErrorWithValue>
Returns true if the full set of stat entries should be checked, and it’s just as lenient as git.
source§impl Any<Abbrev>
impl Any<Abbrev>
sourcepub fn try_into_abbreviation(
&'static self,
hex_len_str: Cow<'_, BStr>,
object_hash: Kind
) -> Result<Option<usize>, Error>
pub fn try_into_abbreviation( &'static self, hex_len_str: Cow<'_, BStr>, object_hash: Kind ) -> Result<Option<usize>, Error>
Convert the given hex_len_str
into the amount of characters that a short hash should have.
If None
is returned, the correct value can be determined based on the amount of objects in the repo.
source§impl Any<Renames>
impl Any<Renames>
sourcepub const fn new_renames(
name: &'static str,
section: &'static dyn Section
) -> Self
Available on crate feature blob-diff
only.
pub const fn new_renames( name: &'static str, section: &'static dyn Section ) -> Self
blob-diff
only.Create a new instance.
sourcepub fn try_into_renames(
&'static self,
value: Result<bool, Error>
) -> Result<Tracking, GenericError>
Available on crate feature blob-diff
only.
pub fn try_into_renames( &'static self, value: Result<bool, Error> ) -> Result<Tracking, GenericError>
blob-diff
only.Try to convert the configuration into a valid rename tracking variant. Use value
and if it’s an error, interpret
the boolean as string
source§impl Any<ObjectFormat>
impl Any<ObjectFormat>
pub fn try_into_object_format( &'static self, value: Cow<'_, BStr> ) -> Result<Kind, GenericErrorWithValue>
source§impl Any<NegotiationAlgorithm>
impl Any<NegotiationAlgorithm>
sourcepub fn try_into_negotiation_algorithm(
&'static self,
name: Cow<'_, BStr>
) -> Result<Algorithm, GenericErrorWithValue>
Available on crate feature credentials
only.
pub fn try_into_negotiation_algorithm( &'static self, name: Cow<'_, BStr> ) -> Result<Algorithm, GenericErrorWithValue>
credentials
only.Derive the negotiation algorithm identified by name
, case-sensitively.
source§impl Any<RecurseSubmodules>
impl Any<RecurseSubmodules>
sourcepub fn try_into_recurse_submodules(
&'static self,
value: Result<bool, Error>
) -> Result<FetchRecurse, GenericErrorWithValue>
Available on crate feature attributes
only.
pub fn try_into_recurse_submodules( &'static self, value: Result<bool, Error> ) -> Result<FetchRecurse, GenericErrorWithValue>
attributes
only.Obtain the way submodules should be updated.
source§impl Any<SslVersion>
impl Any<SslVersion>
pub const fn new_ssl_version( name: &'static str, section: &'static dyn Section ) -> Self
source§impl Any<ProxyAuthMethod>
impl Any<ProxyAuthMethod>
pub const fn new_proxy_auth_method( name: &'static str, section: &'static dyn Section ) -> Self
source§impl Any<FollowRedirects>
impl Any<FollowRedirects>
sourcepub fn try_into_follow_redirects(
&'static self,
value: Cow<'_, BStr>,
boolean: impl FnOnce() -> Result<Option<bool>, Error>
) -> Result<FollowRedirects, GenericErrorWithValue>
Available on crate features blocking-http-transport-reqwest
or blocking-http-transport-curl
only.
pub fn try_into_follow_redirects( &'static self, value: Cow<'_, BStr>, boolean: impl FnOnce() -> Result<Option<bool>, Error> ) -> Result<FollowRedirects, GenericErrorWithValue>
blocking-http-transport-reqwest
or blocking-http-transport-curl
only.Convert value
into the redirect specification, or query the same value as boolean
for additional possible input values.
Note that boolean
only queries the underlying key as boolean, which is a necessity to handle
empty booleans correctly, that is those without a value separator.
source§impl Any<ExtraHeader>
impl Any<ExtraHeader>
source§impl Any<Version>
impl Any<Version>
pub fn try_into_http_version( &'static self, value: Cow<'_, BStr> ) -> Result<HttpVersion, GenericErrorWithValue>
blocking-http-transport-reqwest
or blocking-http-transport-curl
only.source§impl Any<ProxyAuthMethod>
impl Any<ProxyAuthMethod>
pub fn try_into_proxy_auth_method( &'static self, value: Cow<'_, BStr> ) -> Result<ProxyAuthMethod, GenericErrorWithValue>
blocking-http-transport-reqwest
or blocking-http-transport-curl
only.source§impl Any<SslVersion>
impl Any<SslVersion>
pub fn try_into_ssl_version( &'static self, value: Cow<'_, BStr> ) -> Result<SslVersion, Error>
blocking-http-transport-reqwest
or blocking-http-transport-curl
only.source§impl Any<IndexThreads>
impl Any<IndexThreads>
sourcepub fn try_into_index_threads(
&'static self,
value: Cow<'_, BStr>
) -> Result<usize, GenericErrorWithValue>
pub fn try_into_index_threads( &'static self, value: Cow<'_, BStr> ) -> Result<usize, GenericErrorWithValue>
Parse value
into the amount of threads to use, with 1
being single-threaded, or 0
indicating
to select the amount of threads, with any other number being the specific amount of threads to use.
source§impl Any<IndexVersion>
impl Any<IndexVersion>
sourcepub fn try_into_index_version(
&'static self,
value: Result<i64, Error>
) -> Result<Version, GenericError>
pub fn try_into_index_version( &'static self, value: Result<i64, Error> ) -> Result<Version, GenericError>
Try to interpret an integer value as index version.
source§impl Any<Allow>
impl Any<Allow>
sourcepub fn try_into_allow(
&'static self,
value: Cow<'_, BStr>,
scheme: Option<&str>
) -> Result<Allow, Error>
Available on crate features blocking-network-client
or async-network-client
only.
pub fn try_into_allow( &'static self, value: Cow<'_, BStr>, scheme: Option<&str> ) -> Result<Allow, Error>
blocking-network-client
or async-network-client
only.Convert value
into its respective Allow
variant, possibly informing about the scheme
we are looking at in the error.
source§impl Any<Version>
impl Any<Version>
sourcepub fn try_into_protocol_version(
&'static self,
value: Option<Result<i64, Error>>
) -> Result<Protocol, GenericErrorWithValue>
Available on crate features blocking-network-client
or async-network-client
only.
pub fn try_into_protocol_version( &'static self, value: Option<Result<i64, Error>> ) -> Result<Protocol, GenericErrorWithValue>
blocking-network-client
or async-network-client
only.Convert value
into the corresponding protocol version, possibly applying the correct default.
source§impl Any<TagOpt>
impl Any<TagOpt>
sourcepub fn try_into_tag_opt(
&'static self,
value: Cow<'_, BStr>
) -> Result<Tags, GenericErrorWithValue>
pub fn try_into_tag_opt( &'static self, value: Cow<'_, BStr> ) -> Result<Tags, GenericErrorWithValue>
Try to interpret value
as tag option.
Note
It’s heavily biased towards the git command-line unfortunately, and the only value of its kind. Maybe in future more values will be supported which are less about passing them to a sub-process.
source§impl Any<Variant>
impl Any<Variant>
pub fn try_into_variant( &'static self, value: Cow<'_, BStr> ) -> Result<Option<ProgramKind>, GenericErrorWithValue>
blocking-network-client
only.source§impl Any<DurationInMilliseconds>
impl Any<DurationInMilliseconds>
sourcepub const fn new_duration(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_duration( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
source§impl Any<LockTimeout>
impl Any<LockTimeout>
source§impl Any<PushRefSpec>
impl Any<PushRefSpec>
sourcepub const fn new_push_refspec(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_push_refspec( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
source§impl Any<FetchRefSpec>
impl Any<FetchRefSpec>
sourcepub const fn new_fetch_refspec(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_fetch_refspec( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
source§impl Any<UnsignedInteger>
impl Any<UnsignedInteger>
sourcepub const fn new_unsigned_integer(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_unsigned_integer( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
sourcepub fn try_into_usize(
&'static self,
value: Result<i64, Error>
) -> Result<usize, Error>
pub fn try_into_usize( &'static self, value: Result<i64, Error> ) -> Result<usize, Error>
Convert value
into a usize
or wrap it into a specialized error.
source§impl Any<Time>
impl Any<Time>
sourcepub const fn new_time(name: &'static str, section: &'static dyn Section) -> Self
pub const fn new_time(name: &'static str, section: &'static dyn Section) -> Self
Create a new instance.
sourcepub fn try_into_time(
&self,
value: Cow<'_, BStr>,
now: Option<SystemTime>
) -> Result<Time, Error>
pub fn try_into_time( &self, value: Cow<'_, BStr>, now: Option<SystemTime> ) -> Result<Time, Error>
Convert the value
into a date if possible, with now
as reference time for relative dates.
source§impl Any<Boolean>
impl Any<Boolean>
sourcepub const fn new_boolean(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_boolean( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
sourcepub fn enrich_error(
&'static self,
value: Result<bool, Error>
) -> Result<bool, Error>
pub fn enrich_error( &'static self, value: Result<bool, Error> ) -> Result<bool, Error>
Process the value
into a result with an improved error message.
value
is expected to be provided by gix_config::File::boolean()
.
source§impl Any<RemoteName>
impl Any<RemoteName>
sourcepub const fn new_remote_name(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_remote_name( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
sourcepub fn try_into_symbolic_name(
&'static self,
name: Cow<'_, BStr>
) -> Result<BString, Error>
pub fn try_into_symbolic_name( &'static self, name: Cow<'_, BStr> ) -> Result<BString, Error>
Try to validate name
as symbolic remote name and return it.
source§impl<T: Validate> Any<T>
impl<T: Validate> Any<T>
Init other validate implementations
sourcepub const fn new_with_validate(
name: &'static str,
section: &'static dyn Section,
validate: T
) -> Self
pub const fn new_with_validate( name: &'static str, section: &'static dyn Section, validate: T ) -> Self
Create a new instance from name
and section
source§impl<T: Validate> Any<T>
impl<T: Validate> Any<T>
Builder
sourcepub const fn with_subsection_requirement(
self,
requirement: Option<SubSectionRequirement>
) -> Self
pub const fn with_subsection_requirement( self, requirement: Option<SubSectionRequirement> ) -> Self
Set the subsection requirement to non-default values.
sourcepub const fn with_environment_override(self, var: &'static str) -> Self
pub const fn with_environment_override(self, var: &'static str) -> Self
Associate an environment variable with this key.
This is mainly useful for enriching error messages.
sourcepub const fn with_fallback(self, key: &'static dyn Key) -> Self
pub const fn with_fallback(self, key: &'static dyn Key) -> Self
Set a link to another key which serves as fallback to provide a value if this key is not set.
sourcepub const fn with_note(self, message: &'static str) -> Self
pub const fn with_note(self, message: &'static str) -> Self
Attach an informative message to this key.
sourcepub const fn with_deviation(self, message: &'static str) -> Self
pub const fn with_deviation(self, message: &'static str) -> Self
Inform about a deviation in how this key is interpreted.
source§impl<T: Validate> Any<T>
impl<T: Validate> Any<T>
Conversion
source§impl Any<String>
impl Any<String>
sourcepub const fn new_string(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_string( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
source§impl Any<Program>
impl Any<Program>
sourcepub const fn new_program(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_program( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
source§impl Any<Executable>
impl Any<Executable>
sourcepub const fn new_executable(
name: &'static str,
section: &'static dyn Section
) -> Self
pub const fn new_executable( name: &'static str, section: &'static dyn Section ) -> Self
Create a new instance.
Trait Implementations§
source§impl<T: Validate> Key for Any<T>
impl<T: Validate> Key for Any<T>
source§fn validate(&self, value: &BStr) -> Result<(), Error>
fn validate(&self, value: &BStr) -> Result<(), Error>
value
is allowed as value of this key, or return a descriptive error if it is not.source§fn section(&self) -> &dyn Section
fn section(&self) -> &dyn Section
source§fn subsection_requirement(&self) -> Option<&SubSectionRequirement>
fn subsection_requirement(&self) -> Option<&SubSectionRequirement>
source§fn environment_override(&self) -> Option<&str>
fn environment_override(&self) -> Option<&str>
source§fn the_environment_override(&self) -> &str
fn the_environment_override(&self) -> &str
source§fn logical_name(&self) -> String
fn logical_name(&self) -> String
core.bare
for statically known keys, or branch.<name>.key
for complex ones.source§fn full_name(&self, subsection: Option<&BStr>) -> Result<BString, String>
fn full_name(&self, subsection: Option<&BStr>) -> Result<BString, String>
core.bare
, or remote.<subsection>.url
if subsection
is
not None
.
May fail if this key needs a subsection, or may not have a subsection.source§fn validated_assignment(&self, value: &BStr) -> Result<BString, Error>
fn validated_assignment(&self, value: &BStr) -> Result<BString, Error>
value
, suitable for configuration overrides.
Note that this will fail if the key requires a subsection name.source§fn validated_assignment_fmt(
&self,
value: &dyn Display
) -> Result<BString, Error>
fn validated_assignment_fmt( &self, value: &dyn Display ) -> Result<BString, Error>
value
, suitable for configuration overrides.
Note that this will fail if the key requires a subsection name.source§fn validated_assignment_with_subsection(
&self,
value: &BStr,
subsection: &BStr
) -> Result<BString, Error>
fn validated_assignment_with_subsection( &self, value: &BStr, subsection: &BStr ) -> Result<BString, Error>
value
with the keys full name within subsection
, suitable for configuration overrides.
Note that this is only valid if this key supports parameterized sub-sections, or else an error is returned.