Skip to main content

PropMeta

Struct PropMeta 

Source
pub struct PropMeta {
Show 23 fields pub key: &'static str, pub ty: Ty, pub default: Option<Const>, pub merge: Merge, pub scope: Scope, pub parse: Option<Parser>, pub envs: &'static [&'static str], pub deprecated_envs: &'static [&'static str], pub cli: &'static [&'static str], pub bindings: &'static [(&'static str, &'static str)], pub choices: &'static [Const], pub hide: bool, pub deprecated: Option<&'static str>, pub renamed_to: Option<&'static str>, pub aliases: &'static [&'static str], pub optional: Option<bool>, pub help: Option<&'static str>, pub long_help: Option<&'static str>, pub default_note: Option<&'static str>, pub since: Option<&'static str>, pub deprecated_warn_at: Option<&'static str>, pub deprecated_remove_at: Option<&'static str>, pub examples: &'static [&'static str],
}
Expand description

What one setting is.

Every field is const-constructible, so a generated registry is a static with no initializer to run.

Fields§

§key: &'static str

The dotted key, which is also what a config file and config set call it.

§ty: Ty§default: Option<Const>

The value when no layer supplies one.

§merge: Merge§scope: Scope§parse: Option<Parser>

How to split a single string into several values, when a layer hands over text.

§envs: &'static [&'static str]

Environment variables that set it, highest precedence first.

§deprecated_envs: &'static [&'static str]

Deprecated environment aliases, consulted after every current name.

§cli: &'static [&'static str]

The flags that set it, as the spec’s cli node declares them: ["--jobs", "-j"].

Documentation for the most part — an explanation that lists the environment variables and not the flag is answering half the question a user asked. It is also what a generated test can hold the executable binding against, since a spec that declares --jobs and a CLI that never reads it into the setting is the shape of hk’s thirteen dead sources.cli lines.

§bindings: &'static [(&'static str, &'static str)]

Its keys in sources usage does not know about: [("git", "hk.jobs")]. A custom layer asks the registry for its own kind and iterates what it finds, which is the whole mechanism behind hk’s git and pkl layers and aube’s .npmrc.

§choices: &'static [Const]

The only values this setting accepts, when it says.

Empty means anything the type allows. Declared in the spec as choice nodes, where they already reach the docs, the JSON schema and completions — and, until this, nothing that resolved a value, so a CLI documenting three allowed values accepted a fourth in silence.

§hide: bool

Kept out of documentation and completions. Still settable.

§deprecated: Option<&'static str>

Why not to use this any more.

§renamed_to: Option<&'static str>

The setting that replaces this one. A value found under the old key is folded into the new one at the same precedence, with a warning.

§aliases: &'static [&'static str]

Equivalent keys accepted without a rename warning.

§optional: Option<bool>

An explicit optionality contract, when the declaration does not use inference.

§help: Option<&'static str>§long_help: Option<&'static str>§default_note: Option<&'static str>

Prose beside the default, for a default the registry cannot hold — one computed at runtime, or one whose literal alone would mislead (“0 = one per core”).

§since: Option<&'static str>

The release that introduced this setting, when the declaration says.

§deprecated_warn_at: Option<&'static str>

The CLI version that starts warning about a deprecated setting, and the one after which configured values for it are ignored.

§deprecated_remove_at: Option<&'static str>§examples: &'static [&'static str]

Values worth showing a reader, verbatim.

Implementations§

Source§

impl PropMeta

Source

pub const fn new(key: &'static str, ty: Ty) -> Self

A setting with nothing but a key and a type, for a generator or a test to build on.

Source§

impl PropMeta

Source

pub fn refuses<'v>(&self, value: &'v Value) -> Option<&'v Value>

The first value here that this setting does not allow, if there is one.

A collection is checked item by item, because choices on a list<string> mean each item is one of them — the same rule usage g json-schema follows, which puts the enum on every value position rather than on the container. Returning the offender rather than a bool is what lets the warning quote the item that is wrong instead of the whole list it was in.

Source

pub fn allowed(&self) -> String

What it allows, written the way the spec declared them, for a message.

Trait Implementations§

Source§

impl Clone for PropMeta

Source§

fn clone(&self) -> PropMeta

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PropMeta

Source§

impl Debug for PropMeta

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.