Skip to main content

Setting

Trait Setting 

Source
pub trait Setting:
    Copy
    + Eq
    + Sized
    + 'static {
    const SETTING: &'static str;
    const ALL: &'static [Self];

    // Required method
    fn as_str(&self) -> &'static str;

    // Provided methods
    fn parse(raw: &str) -> Result<Self> { ... }
    fn options() -> String { ... }
}
Expand description

A setting whose values are a closed set of wire spellings.

Implemented by setting_enum!. Hand-implementing is possible but there is no reason to: everything here follows mechanically from the variant list.

Required Associated Constants§

Source

const SETTING: &'static str

What this setting is called in an error message — "cache driver".

Lower case and unqualified, because it is interpolated mid-sentence.

Source

const ALL: &'static [Self]

Every variant, in the order they should be listed to a human.

Required Methods§

Source

fn as_str(&self) -> &'static str

The wire spelling — what appears in .env, in the config tree, and in serialised output.

Provided Methods§

Source

fn parse(raw: &str) -> Result<Self>

Parse a wire spelling.

Tolerant in the ways that are unambiguous and no further: surrounding whitespace, letter case, and _ where the canonical spelling uses -. Redis_Cluster is what someone means by redis-cluster; redys is not, and no amount of guessing makes it so.

Source

fn options() -> String

The valid spellings, backtick-quoted and comma-separated.

For an error message, a --help line, or a config-dump command.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§