thalo-rs / esdl

Event-sourcing Schema Definition Language
Apache License 2.0
42 stars 3 forks source link

[Rust Codegen] Allow to use primitive types as custom types ? #4

Open Mcfloy opened 2 years ago

Mcfloy commented 2 years ago

Hello, thanks for the thalo initiative, really good project!

Currently the language is strongly opinionated, as a Int is a i64 however we are missing other types such as i16, i32, u16, u32, u64 (for timestamp)

I would like to have the ability to explicit a type from Rust in a ESDL file. As there are multiple languages involved, it would be probably easier to cheat a bit and explicit the primitive types as custom types.

Do you have any idea about this ?

tqwewe commented 2 years ago

Hey Mcfloy, thanks for opening the issue.

I did include the type Timstamp for timestamp dates. Regarding i16, u32 and other Rust types.. the main goal of ESDL is to not be specific to any language, and just provide basic types which can be mapped to language specific types.

Though, I'm sure there could be some improvements in customizing the generated code. But I don't feel it's too valuable to specify if a number is an 8 bit integer, or 64 bit integer. The main inspiration for this is GraphQL.

Though if people do have this requirement for their projects, I may look into it further.

I'll leave this issue open for now in case anyone has anything to add.

tqwewe commented 2 years ago

Coming back to this, I do thing uint may be useful. I wonder what would be a good way of making it more dynamic.

The options I can thing of now are:

But I'm open to other ideas about this.

Mcfloy commented 2 years ago

I like the protobuf types idea as people that would use ESDL would also be familiar with Protobuf.