Skip to content

bottlesdevs/next-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-config

Typed TOML loading and saving with explicit schema versions and sequential migrations.

use next_config::{Config, load, save};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Config)]
#[config(version = 1)]
struct AppConfig {
    name: String,
    port: u16,
}

let path = "config/app.toml";
let config = AppConfig { name: "demo".into(), port: 8080 };
save(path, &config)?;
let config = load::<AppConfig>(path)?;
# Ok::<(), next_config::error::Error>(())

The path belongs to the caller. Files store a flat _version field; there is no global store or type registration.

For a schema update, increment #[config(version = ...)], implement one Migration for each version step, and register each step with submit_migration!. load applies the chain in order and persists the migrated file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Sponsor this project

Packages

Contributors

Languages