respire_core_sdk 2.0.0-dev.2

Safe Rust binding to the separately distributed Respire Core SDK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Canonical environment names with read-only compatibility for previous clients.
use std::{env::VarError, ffi::OsString};

pub fn var_os(name: &str) -> Option<OsString> {
    std::env::var_os(name).or_else(|| {
        let suffix = name.strip_prefix("RSRS_")?;
        std::env::var_os(format!("ONEMEMORY_{suffix}"))
            .or_else(|| std::env::var_os(format!("RESPIRE_{suffix}")))
    })
}

pub fn var(name: &str) -> Result<String, VarError> {
    match var_os(name) {
        Some(value) => value.into_string().map_err(VarError::NotUnicode),
        None => Err(VarError::NotPresent),
    }
}