INNER CODE UNIT · Rust

from_str

pbeets/rithmic-rs · src/config.rs:97

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "demo" | "development" => Ok(RithmicEnv::Demo),
            "live" | "production" => Ok(RithmicEnv::Live),
            "test" => Ok(RithmicEnv::Test),
            _ => Err(ConfigError::InvalidEnvironment(s.to_string())),
        }
    }
}

/// Why a config could not be built.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ConfigError {
    /// Parsing a [`RithmicEnv`] from a string failed. Holds the string.
    InvalidEnvironment(String),
    /// A configuration value was present but invalid. Nothing returns it
    /// today: a malformed `RITHMIC_REQUEST_TIMEOUT_SECS`, the one value it

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…