gklijs / schema_registry_converter

A crate to convert bytes to something more useable and the other way around in a way Compatible with the Confluent Schema Registry. Supporting Avro, Protobuf, Json schema, and both async and blocking.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please switch to owned strings in SubjectNameStrategy

kitsuneninetails opened this issue · comments

Using slices in this enum makes it harder to use, as the lifetime of whatever string that gets passed in must outlive the SubjectNameStrategy enum that gets created, meaning this enum cannot be passed around to other functions, or stored in long-lived structs (as the owned string the slice comes from is not likely to live that long). The only way around this is to use lifetime specifiers everywhere.

As an alternative, just changing this to an owned string makes it take ownership of the string and then it can get passed around as much as it wants without lifetime specifiers. Furthermore, upon use, this slice always gets cloned into an owned string anyways, which means there isn't really a performance loss here. Plus, it's just a lot more transparent and easy-to-use in my opinion.

A fix for this is proposed in an upcoming PR.

Valid point, looking forward to the pr.