Struct gix::config::tree::keys::Any

source ·
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>

source

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>

source

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>

source

pub fn try_into_encodings( &'static self, value: Option<Cow<'_, BStr>> ) -> Result<Vec<&'static Encoding>, Error>

Available on crate feature 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>

source

pub fn try_into_eol( &'static self, value: Cow<'_, BStr> ) -> Result<Mode, GenericErrorWithValue>

Available on crate feature 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>

source

pub fn try_into_safecrlf( &'static self, value: Cow<'_, BStr> ) -> Result<CrlfRoundTripCheck, GenericErrorWithValue>

Available on crate feature attributes only.

Convert value into the safe-crlf enumeration, if possible.

source§

impl Any<AutoCrlf>

source

pub fn try_into_autocrlf( &'static self, value: Cow<'_, BStr> ) -> Result<AutoCrlf, GenericErrorWithValue>

Available on crate feature attributes only.

Convert value into the safe-crlf enumeration, if possible.

source§

impl Any<Disambiguate>

source

pub fn try_into_object_kind_hint( &'static self, value: Cow<'_, BStr> ) -> Result<Option<ObjectKindHint>, GenericErrorWithValue>

Available on crate feature revision only.

Convert a disambiguation marker into the respective enum.

source§

impl Any<LogAllRefUpdates>

source

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>

source

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>

source

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<Algorithm>

source

pub fn try_into_algorithm( &self, name: Cow<'_, BStr> ) -> Result<Algorithm, Error>

Available on crate feature blob-diff only.

Derive the diff algorithm identified by name, case-insensitively.

source§

impl Any<Renames>

source

pub const fn new_renames( name: &'static str, section: &'static dyn Section ) -> Self

Available on crate feature blob-diff only.

Create a new instance.

source

pub fn try_into_renames( &'static self, value: Result<bool, Error> ) -> Result<Tracking, GenericError>

Available on crate feature 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>

source

pub fn try_into_object_format( &'static self, value: Cow<'_, BStr> ) -> Result<Kind, GenericErrorWithValue>

source§

impl Any<NegotiationAlgorithm>

source

pub fn try_into_negotiation_algorithm( &'static self, name: Cow<'_, BStr> ) -> Result<Algorithm, GenericErrorWithValue>

Available on crate feature credentials only.

Derive the negotiation algorithm identified by name, case-sensitively.

source§

impl Any<RecurseSubmodules>

source

pub fn try_into_recurse_submodules( &'static self, value: Result<bool, Error> ) -> Result<FetchRecurse, GenericErrorWithValue>

Available on crate feature attributes only.

Obtain the way submodules should be updated.

source§

impl Any<SslVersion>

source

pub const fn new_ssl_version( name: &'static str, section: &'static dyn Section ) -> Self

source§

impl Any<ProxyAuthMethod>

source

pub const fn new_proxy_auth_method( name: &'static str, section: &'static dyn Section ) -> Self

source§

impl Any<FollowRedirects>

source

pub 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.

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>

source

pub fn try_into_extra_header( &'static self, values: Vec<Cow<'_, BStr>> ) -> Result<Vec<String>, Error>

Convert a list of values into extra-headers, while failing entirely on illformed UTF-8.

source§

impl Any<Version>

source

pub fn try_into_http_version( &'static self, value: Cow<'_, BStr> ) -> Result<HttpVersion, GenericErrorWithValue>

Available on crate features blocking-http-transport-reqwest or blocking-http-transport-curl only.
source§

impl Any<ProxyAuthMethod>

source

pub fn try_into_proxy_auth_method( &'static self, value: Cow<'_, BStr> ) -> Result<ProxyAuthMethod, GenericErrorWithValue>

Available on crate features blocking-http-transport-reqwest or blocking-http-transport-curl only.
source§

impl Any<SslVersion>

source

pub fn try_into_ssl_version( &'static self, value: Cow<'_, BStr> ) -> Result<SslVersion, Error>

Available on crate features blocking-http-transport-reqwest or blocking-http-transport-curl only.
source§

impl Any<IndexThreads>

source

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>

source

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>

source

pub 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.

Convert value into its respective Allow variant, possibly informing about the scheme we are looking at in the error.

source§

impl Any<Version>

source

pub 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.

Convert value into the corresponding protocol version, possibly applying the correct default.

source§

impl Any<TagOpt>

source

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>

source

pub fn try_into_variant( &'static self, value: Cow<'_, BStr> ) -> Result<Option<ProgramKind>, GenericErrorWithValue>

Available on crate feature blocking-network-client only.
source§

impl Any<DurationInMilliseconds>

source

pub const fn new_duration( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source

pub fn try_into_duration( &'static self, value: Result<i64, Error> ) -> Result<Duration, Error>

Return a valid duration as parsed from an integer that is interpreted as milliseconds.

source§

impl Any<LockTimeout>

source

pub const fn new_lock_timeout( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source

pub fn try_into_lock_timeout( &'static self, value: Result<i64, Error> ) -> Result<Fail, Error>

Return information on how long to wait for locked files.

source§

impl Any<PushRefSpec>

source

pub const fn new_push_refspec( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source§

impl Any<FetchRefSpec>

source

pub const fn new_fetch_refspec( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source§

impl Any<Url>

source

pub const fn new_url(name: &'static str, section: &'static dyn Section) -> Self

Create a new instance.

source

pub fn try_into_url(&'static self, value: Cow<'_, BStr>) -> Result<Url, Error>

Try to parse value as URL.

source§

impl Any<UnsignedInteger>

source

pub const fn new_unsigned_integer( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source

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

pub fn try_into_u64( &'static self, value: Result<i64, Error> ) -> Result<u64, Error>

Convert value into a u64 or wrap it into a specialized error.

source

pub fn try_into_u32( &'static self, value: Result<i64, Error> ) -> Result<u32, Error>

Convert value into a u32 or wrap it into a specialized error.

source§

impl Any<Time>

source

pub const fn new_time(name: &'static str, section: &'static dyn Section) -> Self

Create a new instance.

source

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>

source

pub const fn new_boolean( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source

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>

source

pub const fn new_remote_name( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source

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 Any<All>

Init

source

pub const fn new(name: &'static str, section: &'static dyn Section) -> Self

Create a new instance from name and section

source§

impl<T: Validate> Any<T>

Init other validate implementations

source

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>

Builder

source

pub const fn with_subsection_requirement( self, requirement: Option<SubSectionRequirement> ) -> Self

Set the subsection requirement to non-default values.

source

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.

source

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.

source

pub const fn with_note(self, message: &'static str) -> Self

Attach an informative message to this key.

source

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>

Conversion

source

pub fn try_into_refspec( &'static self, value: Cow<'_, BStr>, op: Operation ) -> Result<RefSpec, Error>

Try to convert value into a refspec suitable for the op operation.

source

pub fn try_into_string( &'static self, value: Cow<'_, BStr> ) -> Result<String, Error>

Try to interpret value as UTF-8 encoded string.

source§

impl Any<String>

source

pub const fn new_string( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source§

impl Any<Program>

source

pub const fn new_program( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source§

impl Any<Executable>

source

pub const fn new_executable( name: &'static str, section: &'static dyn Section ) -> Self

Create a new instance.

source§

impl Any<Path>

source

pub const fn new_path(name: &'static str, section: &'static dyn Section) -> Self

Create a new instance.

Trait Implementations§

source§

impl<T: Validate> Debug for Any<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Validate> Display for Any<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: Validate> Key for Any<T>

source§

fn name(&self) -> &str

The key’s name, like url in remote.origin.url.
source§

fn validate(&self, value: &BStr) -> Result<(), Error>

See if value is allowed as value of this key, or return a descriptive error if it is not.
source§

fn section(&self) -> &dyn Section

The section containing this key. Git configuration has no free-standing keys, they are always underneath a section.
source§

fn subsection_requirement(&self) -> Option<&SubSectionRequirement>

The return value encodes three possible states to indicate subsection requirements Read more
Return the link to other resources, if available.
source§

fn note(&self) -> Option<&Note>

Return a note about this key, if available.
source§

fn environment_override(&self) -> Option<&str>

Return the name of an environment variable that would override this value (after following links until one is found).
source§

fn the_environment_override(&self) -> &str

Return the environment override that must be set on this key. Read more
source§

fn logical_name(&self) -> String

Produce a name that describes how the name is composed. This is core.bare for statically known keys, or branch.<name>.key for complex ones.
source§

fn full_name(&self, subsection: Option<&BStr>) -> Result<BString, String>

The full name of the key for use in configuration overrides, like 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>

Return an assignment with the keys full name to 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>

Return an assignment with the keys full name to 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>

Return an assignment to 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.

Auto Trait Implementations§

§

impl<T = All> !RefUnwindSafe for Any<T>

§

impl<T = All> !Send for Any<T>

§

impl<T = All> !Sync for Any<T>

§

impl<T> Unpin for Any<T>where T: Unpin,

§

impl<T = All> !UnwindSafe for Any<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.