soml

Crates.iosoml
lib.rssoml
version0.2.0
created_at2025-07-17 22:21:53.654776+00
updated_at2025-08-04 23:38:15.572065+00
descriptionA lightweight Serde-compatible TOML parser
homepage
repositoryhttps://github.com/staticintlucas/soml
max_upload_size
id1758249
size731,803
Lucas Jansen (staticintlucas)

documentation

README

soml (smol toml)Test StatusCrate VersionRust Version

A lightweight Serde-compatible TOML parser written in Rust

but why?

The toml crate has lots of amazing features, but that makes it really heavy in terms of binary size and compile times. For one of my other projects toml accounted for over 15% of the compiled binary size despite only being used to read one small config file.

This project designed to sit at the opposite end of the spectrum, offering basic TOML support for Serde with a much smaller footprint. See the comparison table below for a more detailed comparison of TOML crates.

We also aim to be mostly API-compatibility with the toml crate, so migrating to (or from) soml should be relatively easy.

Features

Feature Default Description

std | ✅ | Enables std support strict | ✅ | Enables extra checks for strict compliance with the TOML spec (see below) datetime | ✅ | Enables support for TOML date-time values

The strict feature

The (enabled by default) strict feature adds certain checks required to validate compliance with the TOML spec. These checks can be disabled allowing the parser accept some unambiguous but not-technically-valid TOML. For some applications disabling the strict feature could yield a small performance improvement.

The following checks are currently disabled without the strict feature:

  • Validate comments are valid UTF-8
  • Scan comments for disallowed control characters
  • Range checking on date-time values
    • For example, 2024-14-35T25:61:63 is invalid

ℹ️ Important
The exact list of checks controlled by the strict feature is considered an implementation detail and is subject to change. Changes to which not-strictly-valid TOML is accepted when strict is disabled is not considered a breaking change.

Comparison of TOML crates

These tables are autogenerated by binsize/main.py:

Deserialize-only

Crate Version Size * Maintained TOML version
soml 0.2.0 103 KiB 1.0
soml
(datetime disabled)
0.2.0 98 KiB 1.0 †
toml 0.9.5 164 KiB 1.0
toml 0.8.23 231 KiB 1.0
toml 0.5.11 114 KiB 0.5
basic-toml 0.1.10 117 KiB 0.5 †

* Increase in code (.text) size compared to just reading/writing a file without (de)serializing. This is calculated using cargo-bloat with the default release profile.
Does not support TOML date-time types.

Deserialize and Serialize

Crate Version Size * Maintained TOML version
soml 0.2.0 128 KiB 1.0
soml
(datetime disabled)
0.2.0 122 KiB 1.0 †
toml 0.9.5 186 KiB 1.0
toml 0.8.23 320 KiB 1.0
toml 0.5.11 127 KiB 0.5
basic-toml 0.1.10 127 KiB 0.5 †

* Increase in code (.text) size compared to just reading/writing a file without (de)serializing. This is calculated using cargo-bloat with the default release profile.
Does not support TOML date-time types.

Licence

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt