logdna / logdna-rust

Send logs to LogDNA from rust applications
MIT License
2 stars 11 forks source link

KeyValueMap, Params, RequestTemplate and Client: Clone? #25

Open peter-lyons-kehl opened 2 years ago

peter-lyons-kehl commented 2 years ago

Hi at LogDNA/Mezmo crate maintainer/creator,

Thank you for this Rust library. It works marvels.

I see that you guard your API, to make it future proof/implementation-independent. Like KeyValueMap is a value type around HashMap, rather than HashMap itself.

  1. If you didn't intend KeyValueMap to be Clone, you may want to make it a one-field struct {} rather than a one-field tuple, because a tuple automatically is Clone or even Copy (and I believe it's automatically Debug, too) if all its fields are Clone or Copy (or Debug). Of course, you may have intended KeyValueMap to be Clone, which I'd be thankful for. (I've checked and there are no other named tuples around: egrep -r "struct +[a-zA-Z_]+ *\(" src.)

  2. On the other hand, Clone is very handy. For example, Axum requires the (HTTP GET/POST...) service handler function/closure to be Clone (https://docs.rs/axum/latest/axum/handler/trait.Handler.html). Currently there's no way to instantiate one Client, use it before spinning up Axum and pass it to the handler(s), too.

So it would help if KeyValueMap, Params, RequestTemplate and Client (or at least Client and/or RequestTemplate) were Clone, please.