Skip to main content

EnvKey

Trait EnvKey 

Source
pub trait EnvKey: Copy + 'static {
    type Value: Clone + Send + 'static;

    // Required methods
    fn field_type() -> &'static [u8] ⓘ;
    fn value_type() -> &'static [u8] ⓘ;
    fn key_path() -> u64;
    fn buffer_bytes() -> usize;
    unsafe fn decode(buf: &[u8]) -> Self::Value;
    fn encode(value: &Self::Value) -> u8;
}
Expand description

One \EnvironmentValues property, as a type.

Each implementation names a property and says how to read its value back. Adding another is three resolve entries and one impl.

Required Associated Types§

Source

type Value: Clone + Send + 'static

What the property holds.

Required Methods§

Source

fn field_type() -> &'static [u8] ⓘ

The mangled Environment<Value>, NUL-terminated, for the field record.

Source

fn value_type() -> &'static [u8] ⓘ

The mangled Value on its own.

field_type is what the reflection record needs; this is what a modifier generic over V needs, and the two are different manglings of different types.

Source

fn key_path() -> u64

\EnvironmentValues.<property>, built once.

Source

fn buffer_bytes() -> usize

How many bytes the getter writes.

Source

unsafe fn decode(buf: &[u8]) -> Self::Value

Read Value out of the getter’s @out buffer.

§Safety

buf must be buffer_bytes of a valid Value.

Source

fn encode(value: &Self::Value) -> u8

The tag a Value is stored as — decode’s inverse.

Reading the environment only ever needed one direction. Writing one — transformEnvironment hands a handler the current value and stores whatever it returns — needs the other, and a key that can do one but not the other is half a key.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§