#config-file #configuration #setting

config-types

A library which provides ergononic types for configuration files

3 releases (stable)

new 1.1.0 Mar 10, 2025
1.0.0 Mar 7, 2025
0.1.0 Mar 7, 2025

#246 in Configuration

Download history 201/week @ 2025-03-02 155/week @ 2025-03-09

356 downloads per month

MIT/Apache

13KB
282 lines

Config types for rust

This is a collection of config types for Rust. It is intended to be used with

  • config
  • figment
  • or any other configuration library that supports serde.

Usage

See example for usage.

DurationConf

DurationConf is a wrapper around std::time::Duration that allows you to specify duration in human readable format in your config.

For example, you can specify duration in your config file like this:

duration = "5m"

Supported suffixes(case insensitive):

  • ns - nanoseconds
  • us - microseconds
  • ms - milliseconds
  • s - seconds
  • m - minutes
  • h - hours

ByteSizeConf

ByteSizeConf allows you to specify byte size in your config.

For example, if you want to specify max file size in your config file, you can do it like this:

max_file_size = "10Mi"

Supported suffixes(case insensitive):

  • B - bytes
  • Ki - kibibytes
  • Kb - kilobytes
  • Mi - mebibytes
  • Mb - megabytes
  • Gi - gibibytes
  • Gb - gigabytes
  • Ti - tebibytes
  • Tb - terabytes

Dependencies

~2.4–4MB
~74K SLoC