Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kodraus/sval_protobuf
Protobuf-compatible encoding using sval
https://github.com/kodraus/sval_protobuf
Last synced: 2 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-22T11:24:44.000Z (3 months ago)
- Last Synced: 2024-10-23T03:25:54.464Z (3 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`
[![Rust](https://github.com/KodrAus/sval_protobuf/workflows/protobuf/badge.svg)](https://github.com/KodrAus/sval_protobuf/actions)
[![Latest version](https://img.shields.io/crates/v/sval_protobuf.svg)](https://crates.io/crates/sval_protobuf)
[![Documentation Latest](https://docs.rs/sval_protobuf/badge.svg)](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.2"
```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",
});
```