majiayu000/spellbook / skills/rust-project
rust-project
UnverifiedModern Rust project architecture guide for 2025. Use when creating Rust projects (CLI, web services, libraries). Covers workspace structure, error handling, async patterns, and idiomatic Rust best practices.
templates/web-service/src/config.rs
View on GitHubuse config::{Config, Environment, File};
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct AppConfig {
pub listen_addr: String,
pub database_url: String,
pub log_level: String,
}
impl Default for AppConfig {
fn default() -> Self {
Self {
listen_addr: "127.0.0.1:3000".into(),
database_url: "postgres://localhost/myapp".into(),
log_level: "debug".into(),
}
}
}
pub fn load() -> anyhow::Result<AppConfig> {
let config = Config::builder()
// Start with defaults
.set_default("listen_addr", "127.0.0.1:3000")?
.set_default("log_level", "debug")?
// Load from config file if exists
.add_source(File::with_name("config/default").required(false))
.add_source(File::with_name("config/local").required(false))
// Override with environment variables (APP_ prefix)
.add_source(
Environment::with_prefix("APP")
.separator("__")
.try_parsing(true),
)
.build()?;
Ok(config.try_deserialize()?)
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |