[go: up one dir, main page]

Trait Key

Source
pub trait Key: Debug {
Show 13 methods // Required methods fn name(&self) -> &str; fn validate(&self, value: &BStr) -> Result<(), Error>; fn section(&self) -> &dyn Section; // Provided methods fn subsection_requirement(&self) -> Option<&SubSectionRequirement> { ... } fn link(&self) -> Option<&Link> { ... } fn note(&self) -> Option<&Note> { ... } fn environment_override(&self) -> Option<&str> { ... } fn the_environment_override(&self) -> &str { ... } fn logical_name(&self) -> String { ... } fn full_name(&self, subsection: Option<&BStr>) -> Result<BString, String> { ... } fn validated_assignment(&self, value: &BStr) -> Result<BString, Error> { ... } fn validated_assignment_fmt( &self, value: &dyn Display, ) -> Result<BString, Error> { ... } fn validated_assignment_with_subsection( &self, value: &BStr, subsection: &BStr, ) -> Result<BString, Error> { ... }
}
Expand description

A leaf-level entry in the git configuration, like url in remote.origin.url.

Required Methods§

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.

Provided Methods§

Source

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

The return value encodes three possible states to indicate subsection requirements

  • None = subsections may or may not be used, the most flexible setting.
  • Some([Requirement][SubSectionRequirement]) = subsections must or must not be used, depending on the value

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.

§Panics

If no environment variable is set

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.

Trait Implementations§

Source§

impl AsKey for &dyn Key

Source§

fn as_key(&self) -> KeyRef<'_>

Return a parsed key reference, containing all relevant parts of a key. For instance, remote.origin.url such key would yield access to ("remote", Some("origin"), "url") while user.name would yield ("user", None, "name"). Read more
Source§

fn try_as_key(&self) -> Option<KeyRef<'_>>

Return a parsed key reference, containing all relevant parts of a key. For instance, remote.origin.url such key would yield access to ("remote", Some("origin"), "url") while user.name would yield ("user", None, "name").

Implementors§

Source§

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