#serialization #sval #no-std

no-std sval_protobuf

protobuf encoding for sval

7 releases

new 0.2.3 Mar 26, 2025
0.2.2 Oct 22, 2024
0.1.2 Mar 27, 2024
0.1.1 Jan 22, 2024
0.1.0 Oct 15, 2023

#1593 in Encoding

Download history 217/week @ 2024-12-04 261/week @ 2024-12-11 28/week @ 2024-12-18 335/week @ 2025-01-01 585/week @ 2025-01-08 188/week @ 2025-01-15 291/week @ 2025-01-22 300/week @ 2025-01-29 306/week @ 2025-02-05 266/week @ 2025-02-12 298/week @ 2025-02-19 208/week @ 2025-02-26 209/week @ 2025-03-05 728/week @ 2025-03-12 396/week @ 2025-03-19

1,612 downloads per month
Used in emit_otlp

Apache-2.0 OR MIT

56KB
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.3"

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

~175KB