fire-protobuf

Crates.iofire-protobuf
lib.rsfire-protobuf
version0.1.5
sourcesrc
created_at2023-01-16 22:05:03.619184
updated_at2023-10-31 00:13:10.937678
descriptionRust only protobuf implementation
homepage
repositoryhttps://github.com/fire-lib/fire-stream
max_upload_size
id760622
size51,714
Sören Meier (soerenmeier)

documentation

README

Fire Protobuf

A library to encode and decode data in the protobuf format. Supports derive.

Example

use fire_protobuf::{EncodeMessage, DecodeMessage, from_slice, to_vec};

#[derive(Debug, PartialEq, Eq, EncodeMessage, DecodeMessage)]
struct MyData {
	#[field(1)]
	s: String,
	#[field(5)]
	items: Vec<Item>
}

#[derive(Debug, PartialEq, Eq, EncodeMessage, DecodeMessage)]
struct Item {
	#[field(1)]
	name: String,
	#[field(2)]
	value: u32
}

// get the data as bytes
let mut data = MyData {
	s: "data".into(),
	items: vec![
		Item {
			name: "1".into(),
			value: 1
		},
		Item {
			name: "2".into(),
			value: 2
		}
	]
};

let bytes = to_vec(&mut data).unwrap();
let n_data = from_slice(&bytes).unwrap();
assert_eq!(data, n_data);
Commit count: 55

cargo fmt