6 releases

new 0.2.2 Oct 22, 2024
0.2.1 Oct 22, 2024
0.1.2 Mar 27, 2024
0.1.1 Jan 22, 2024
0.1.0 Oct 15, 2023

#658 in Encoding

Download history 1/week @ 2024-07-09 1/week @ 2024-07-16 7/week @ 2024-07-23 67/week @ 2024-07-30 65/week @ 2024-08-06 56/week @ 2024-08-13 80/week @ 2024-08-20 143/week @ 2024-08-27 282/week @ 2024-09-03 299/week @ 2024-09-10 136/week @ 2024-09-17 73/week @ 2024-09-24 217/week @ 2024-10-01 222/week @ 2024-10-08 906/week @ 2024-10-15

1,429 downloads per month
Used in emit_otlp

Apache-2.0 OR MIT

49KB
1.5K SLoC

sval_protobuf

Rust Latest version Documentation Latest

protobuf support for sval.

This library implements a binary encoding for sval::Values that's compatible with the protobuf wire format.

It doesn't require protoc.

Getting started

Add sval_protobuf and sval to your Cargo.toml:

[dependencies.sval]
version = "2"

[dependencies.sval_derive]
version = "2"

[dependencies.sval_protobuf]
version = "0.2.2"

Derive sval::Value on your types and encode them as protobuf messages:

#[macro_use]
extern crate sval_derive;

#[derive(Value)]
pub struct Record<'a> {
    id: i32,
    title: &'a str,
    data: &'a str,
}

let encoded = sval_protobuf::stream_to_protobuf(Record {
    id: 42,
    title: "My Message",
    data: "Some extra contents",
});

Dependencies

~160KB