Crates.io | constrained_type |
lib.rs | constrained_type |
version | 0.2.5 |
source | src |
created_at | 2020-03-11 23:27:50.605737 |
updated_at | 2021-08-14 00:50:32.893679 |
description | On the fly value objects in Rust. |
homepage | |
repository | https://www.github.com/ronlobo/constrained_type |
max_upload_size | |
id | 217685 |
size | 40,236 |
This is a simple project to help create on the fly value objects aka constrained types.
It provides some helper functions to construct these from Rust primitives and turn them into domain primitives, new types, value objects, you name it.
Constrained types guarantee valid state and behaviour from dynamic runtime inputs after construction.
This can be useful when creating simple wrapper types, so called newtypes, value objects or domain primitives.
If an input does not meet the validation criteria, it returns an error result instead.
The goal is to remove defensive code statements, ease implementing business invariants and guarantee correct state at runtime.
Heavily inspired by "Domain Modelling Made Functional".
For more complex types, please take a look at the various builder crates.