Skip to main content

EnvFrame

Trait EnvFrame 

Source
pub trait EnvFrame {
    // Required methods
    fn marshal(val: Vec<Pair>) -> String;
    fn parse(content: String) -> Vec<Pair>;
    fn new(name: String) -> Env;
    fn load(&mut self, e: &str);
    fn get(&self, k: &str) -> Wrapper;
    fn get_debug(self) -> Vec<Pair>;
    fn set(&mut self, k: &str, v: Pair);
    fn debug(self);
    fn upload(path: &str, Pairs: Vec<Pair>) -> Env;
    fn global_env(&mut self);
    fn get_local(&self, k: &str) -> Wrapper;
    fn get_global(&self, k: &str) -> Wrapper;
}
Expand description

A trait that defines the core behavior of an environment system.

This trait is mainly intended for advanced use cases where users want to implement a custom environment backend while keeping compatibility with the rust-env API.

Most users do NOT need to implement this trait directly.

§Purpose

EnvFrame allows you to:

  • Define custom storage for environment data
  • Customize parsing and serialization logic
  • Extend or replace default Env behavior

§Example

use rust_env::{EnvFrame, Pair};

struct CustomEnv {
    data: Vec<Pair>,
    global: Vec<Pair>,
    path: String,
}

impl EnvFrame for CustomEnv {
    // implement custom behavior here
}

§Note

This trait is intended for advanced extensibility only. Standard usage should rely on Env.

Required Methods§

Source

fn marshal(val: Vec<Pair>) -> String

Source

fn parse(content: String) -> Vec<Pair>

Source

fn new(name: String) -> Env

Source

fn load(&mut self, e: &str)

Source

fn get(&self, k: &str) -> Wrapper

Source

fn get_debug(self) -> Vec<Pair>

Source

fn set(&mut self, k: &str, v: Pair)

Source

fn debug(self)

Source

fn upload(path: &str, Pairs: Vec<Pair>) -> Env

Source

fn global_env(&mut self)

Source

fn get_local(&self, k: &str) -> Wrapper

Source

fn get_global(&self, k: &str) -> Wrapper

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§