6 releases

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

#1749 in Encoding

Download history 210/week @ 2024-10-03 446/week @ 2024-10-10 1123/week @ 2024-10-17 339/week @ 2024-10-24 165/week @ 2024-10-31 244/week @ 2024-11-07 121/week @ 2024-11-14 215/week @ 2024-11-21 197/week @ 2024-11-28 225/week @ 2024-12-05 228/week @ 2024-12-12 13/week @ 2024-12-19 3/week @ 2024-12-26 570/week @ 2025-01-02 382/week @ 2025-01-09 238/week @ 2025-01-16

1,193 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

~165KB