async-try-from
async-try-from provides a set of traits for defining asynchronous object creation and validation patterns in Rust. This crate builds on the async-trait library to allow trait-based asynchronous construction, integrity checks, and more.
Overview
AsyncTryFrom<X>: Asynchronously create a typeTfrom some inputX.ValidateIntegrity: Perform synchronous integrity checks on an object.AsyncCreateWithAndValidate<X>: Combines creation and validation into one asynchronous routine.AsyncPathValidatorandAsyncFindItems: Simplify common filesystem-related validations and item discovery.
Usage
Below is a minimal working example demonstrating how to implement AsyncTryFrom and ValidateIntegrity, and then use the combined AsyncCreateWithAndValidate trait for easy creation-and-validation in a single call.
Create a file, for example examples/basic_usage.rs, and paste in the following full Rust code:
Then run:
to see the async creation and validation in action.
Features
- Simple Trait Definitions: Define async creation logic in a concise manner with
AsyncTryFrom. - Optional Validation: Use
ValidateIntegrityto provide domain-specific checks on newly created objects. - Combined Flow:
AsyncCreateWithAndValidatemerges creation and validation into a single method for convenience. - Filesystem Helpers:
AsyncPathValidatorandAsyncFindItemscan be used to handle path validation and item discovery.
License
This project is licensed under the MIT License.