1 unstable release
Uses new Rust 2024
| 0.1.0 | Aug 4, 2025 |
|---|
#2317 in Procedural macros
91KB
1.5K
SLoC
oh_my_toml
This is a template for my Rust projects.
Installation
Supported platforms: Linux, macOS and Windows
Shell
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/nik-rev/oh_my_toml/releases/latest/download/oh_my_toml-installer.sh | sh
PowerShell
powershell -ExecutionPolicy Bypass -c "irm https://github.com/nik-rev/oh_my_toml/releases/latest/download/oh_my_toml-installer.ps1 | iex"
Homebrew
brew install nik-rev/tap/oh_my_toml
Cargo
cargo install oh_my_toml
Nix
nix profile install github:nik-rev/oh_my_toml/main
License
This repository is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
lib.rs:
This crate contains the OhMyToml derive macro
Attributes
Field attributes
defaultordefault = value: If the field is missing then the default value for the field will be usedon_default = "error": If thedefaultvalue is used, then an error will be reported - but we still get our data. This allows for error recovery.rename = "...": Renames this field. When checking for keys in the TOML, we will expect the renamed value.
Container attributes
default_all: Appliesdefaultto each field- To opt-out for a single field, use
require
- To opt-out for a single field, use
on_default_all = "error": Applieson_default = "error"to each field- To opt-out for a single field, use
on_default = "ok"on the field
- To opt-out for a single field, use
rename_all = "...": Renames all fields to use a different case. Available cases are:"lowercase""UPPERCASE""PascalCase""camelCase""snake_case""SCREAMING_SNAKE_CASE""kebab-case""SCREAMING-KEBAB-CASE""Train-Case""Title Case"
Implementations
The DeserializeItem and DeserializeValue are
implemented for the following types:
Implementations provided
- Primitive types:
- Non-zero types:
- Atomic types:
- Miscellaneous types:
- Tuples up to size 16
PhantomData
- Collections:
- Arrays of any size
[T; N] BTreeSet<T>BTreeMap<String, T>BinaryHeap<T>LinkedList<T>Vec<T>VecDeque<T>HashSet<T>HashMap<String, T>NonEmpty<T>since we use it in the public API
- Arrays of any size
- Network types:
- Strings:
- Unprocessed types:
Additionally, we provide Spanned<T> which allows you to wrap any type that can be deserialized from TOML
to obtain its SourceSpan that represents the location of the type in the TOML
file itself - to use as you please.
Dependencies
~14MB
~256K SLoC