cloudevents / sdk-rust

Rust library to interact with CloudEvents
Apache License 2.0
177 stars 61 forks source link

Event does not have `new` method #207

Open xiaoas opened 1 year ago

xiaoas commented 1 year ago

Users expect to use Event::new() to construct a event. According to API guideline: https://rust-lang.github.io/api-guidelines/predictability.html

ozabalaferrera commented 2 weeks ago

I believe this is intentional. Instead, the builder pattern is used to force compliance with the different CloudEvent Spec versions (0.3 and 1.0). It aligns with this note in the API guidelines:

If your type has a multiplicity of construction options though, consider the builder pattern (C-BUILDER) instead.