Skip to main content

Host

pub trait Host {
    // Required methods
    fn get(&mut self, name: String) -> Result<Option<String>, ErrorCode>;
    fn set(&mut self, name: String, value: String) -> Result<(), ErrorCode>;
    fn export_env(
        &mut self,
        name: String,
        value: String,
    ) -> Result<(), ErrorCode>;
}

Required Methods§

Source

fn get(&mut self, name: String) -> Result<Option<String>, ErrorCode>

Outer result carries denial; inner option distinguishes “variable not set” from “variable set to empty string”.

Source

fn set(&mut self, name: String, value: String) -> Result<(), ErrorCode>

Source

fn export_env(&mut self, name: String, value: String) -> Result<(), ErrorCode>

Export a variable to the environment (like export VAR=val in the shell). Named export-env rather than export because export is a reserved WIT keyword.

Implementations on Foreign Types§

Source§

impl<_T: Host + ?Sized> Host for &mut _T

Source§

fn get(&mut self, name: String) -> Result<Option<String>, ErrorCode>

Outer result carries denial; inner option distinguishes “variable not set” from “variable set to empty string”.

Source§

fn export_env(&mut self, name: String, value: String) -> Result<(), ErrorCode>

Export a variable to the environment (like export VAR=val in the shell). Named export-env rather than export because export is a reserved WIT keyword.

Source§

fn set(&mut self, name: String, value: String) -> Result<(), ErrorCode>

Implementors§