https://github.com/kodraus/sval_protobuf
Protobuf-compatible encoding using sval
https://github.com/kodraus/sval_protobuf
Last synced: 3 months ago
JSON representation
Protobuf-compatible encoding using sval
- Host: GitHub
- URL: https://github.com/kodraus/sval_protobuf
- Owner: KodrAus
- License: apache-2.0
- Created: 2023-08-30T11:08:14.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T11:24:44.000Z (9 months ago)
- Last Synced: 2025-03-26T07:04:12.490Z (4 months ago)
- Language: Rust
- Size: 80.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# `sval_protobuf`
[](https://github.com/KodrAus/sval_protobuf/actions)
[](https://crates.io/crates/sval_protobuf)
[](https://docs.rs/sval_protobuf)[protobuf](https://protobuf.dev/) support for [`sval`](https://docs.rs/sval/latest/sval/).
This library implements a binary encoding for `sval::Value`s that's compatible with the
protobuf [wire format](https://protobuf.dev/programming-guides/encoding/).It doesn't require `protoc`.
## Getting started
Add `sval_protobuf` and `sval` to your `Cargo.toml`:
```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:
```rust
#[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",
});
```