Skip to main content

KnobValue

Trait KnobValue 

Source
pub trait KnobValue:
    Sized
    + Clone
    + Send
    + Sync
    + 'static {
    const TYPE_NAME: &'static str;

    // Required methods
    fn parse_knob(s: &str) -> Option<Self>;
    fn render_knob(&self) -> String;
}
Expand description

A type usable as a knob value: parseable from the string sources (env / API) and renderable for listing.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

Required Methods§

Source

fn parse_knob(s: &str) -> Option<Self>

Parse from a source string. None means “unset/invalid”: the resolver falls through to the next source rather than overriding with garbage.

Source

fn render_knob(&self) -> String

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl KnobValue for bool

Source§

const TYPE_NAME: &'static str = "bool"

Source§

fn parse_knob(s: &str) -> Option<bool>

Source§

fn render_knob(&self) -> String

Source§

impl KnobValue for f32

Source§

const TYPE_NAME: &'static str = "f32"

Source§

fn parse_knob(s: &str) -> Option<f32>

Source§

fn render_knob(&self) -> String

Source§

impl KnobValue for i64

Source§

const TYPE_NAME: &'static str = "i64"

Source§

fn parse_knob(s: &str) -> Option<i64>

Source§

fn render_knob(&self) -> String

Source§

impl KnobValue for usize

Source§

const TYPE_NAME: &'static str = "usize"

Source§

fn parse_knob(s: &str) -> Option<usize>

Source§

fn render_knob(&self) -> String

Source§

impl<T> KnobValue for Option<T>
where T: KnobValue,

Optional knob: None is the unset/default state (e.g. “autodetect”), Some is an explicit override. A source string that does not parse as T is treated as unset, so the resolver falls through to the next source.

Source§

const TYPE_NAME: &'static str = "option"

Source§

fn parse_knob(s: &str) -> Option<Option<T>>

Source§

fn render_knob(&self) -> String

Implementors§

Source§

impl KnobValue for String

Source§

const TYPE_NAME: &'static str = "string"