LINE1 10 20 30 40 50 60 70 80 90 1001use std::env;2use std::path::PathBuf;34use anyhow::{Context, Result};56pub struct Config {7 pub bind_address: String,8 pub port: u16,9 pub db_path: PathBuf,10}1112impl Config {13 14 15 pub fn from_env() -> Result<Self> {16 let port = env::var("PORT")17 .unwrap_or_else(|_| "8080".to_string())18 .parse()19 .context("PORT must be a port number")?;20 Ok(Self {21 bind_address: env::var("BIND_ADDRESS").unwrap_or_else(|_| "127.0.0.1".to_string()),22 port,23 db_path: env::var_os("DB_PATH")24 .map_or_else(|| PathBuf::from("cairn.db"), PathBuf::from),25 })26 }27}