first commit
This commit is contained in:
commit
6d3ea3e2a6
43 files changed
+8204
No files matched your search
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "meow-proto"
|
||||
description = "Meow protocol v2 wire types (generated from proto/meow.proto)"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
prost = "0.14"
|
||||
|
||||
[build-dependencies]
|
||||
prost-build = "0.14"
|
||||
protox = "0.9"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,9 @@
|
||||
//! Compiles `proto/meow.proto` with protox (pure Rust): no `protoc` required.
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let proto_dir = "../../proto";
|
||||
let file = format!("{proto_dir}/meow.proto");
|
||||
println!("cargo:rerun-if-changed={file}");
|
||||
let fds = protox::compile([file], [proto_dir])?;
|
||||
prost_build::Config::new().compile_fds(fds)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//! Meow protocol v2 wire types.
|
||||
//!
|
||||
//! Generated from `rust/proto/meow.proto`. This crate contains no logic besides
|
||||
//! small encoding helpers; protocol semantics live in `meow-core`.
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![cfg_attr(not(test), warn(clippy::unwrap_used, clippy::expect_used))]
|
||||
|
||||
#[allow(clippy::all, missing_docs)]
|
||||
pub mod v2 {
|
||||
include!(concat!(env!("OUT_DIR"), "/meow.v2.rs"));
|
||||
}
|
||||
|
||||
pub use prost::Message;
|
||||
|
||||
/// Current protocol version carried in every top-level wire object.
|
||||
pub const PROTOCOL_VERSION: u32 = 2;
|
||||
|
||||
/// Decode helper returning a uniform error type.
|
||||
pub fn decode<M: Message + Default>(bytes: &[u8]) -> Result<M, prost::DecodeError> {
|
||||
M::decode(bytes)
|
||||
}
|
||||
|
||||
/// Encode helper.
|
||||
pub fn encode<M: Message>(msg: &M) -> Vec<u8> {
|
||||
msg.encode_to_vec()
|
||||
}
|
||||
Reference in new issue
Block a user