Tuco
Tuco can automatically generate tuple representations of simple types. This is helpful if you want your API to expose convertible types. Down converting a struct to a tuple erases the struct field names resulting in an object which is up convertible to a struct with the similar field composition.
Using #[derive(Tuco)] Will automatically derive Tuco and generate a tuple representation of your struct and assign it to the associated type Tuco::Tuple
Tuco can be used in places where data serialization is used with some differences:
- Conversion operations are validated at compile time.
- Since tuples are unnamed, any matching tuple shape may be used to construct your type. No further integrity checks are applied at this time.
- Tuco does not automatically serialize your types to string data.
Todo
- Support structs with named fields
- Support structs with unnamed fields
- Support nested tuco
- Support structs with generic types
- Reduce single element structs into their inner type, instead of using single element tuples.
- Tests
- Documentation
- Compiler errors
Example
Output:
MyNestedStruct { x: 10, y: MyStruct { a: 1, b: "qwe", c: true }, z: false }
MyOtherNestedStruct { x: 10, y: MyOtherStruct { x: 1, y: "qwe", z: true }, z: false }