pierresouchay / consul-rust

Rust client libray for Consul HTTP API
Apache License 2.0
92 stars 48 forks source link

KV Values should be base64 decoded #31

Open fussybeaver opened 4 years ago

fussybeaver commented 4 years ago

Currently, KV Values are returned as base64 encoded Strings containing arbitrary data. These could be decoded transparently by the library.

stusmall commented 4 years ago

Thank you for this. I'll fix this.

pierresouchay commented 4 years ago

It should be decoded as Option<bytes[]>

Since most utils around Consul are working with UTF-8, we might add helper to decode, as UTF-8 Readers, but in any case, this is Optional byte[] data

jmcconnell26 commented 4 years ago

Added this in https://github.com/stusmall/consul-rust/pull/42

theirix commented 1 year ago

Unfortunately, it cannot be achieved with a current KVPair struct having value: String without breaking changes in API. Non-string content cannot be decoded transparently to String.

Refactoring in PR #20 stores an optional byte array (value: Vec<u8>) in a value with a custom serde, and fixes this problem. But it is a breaking API change too.