Skip to main content

prost_wireformat

Macro prost_wireformat 

Source
macro_rules! prost_wireformat {
    ($wrapper_vis:vis $wrapped_type:ty as $vis:vis $new_type:ident, derive($($derives:path),* $(,)?)) => { ... };
    ($wrapper_vis:vis $wrapped_type:ty as $vis:vis $new_type:ident) => { ... };
    (@impl $wrapped_type:ty, $vis:vis, $new_type:ident) => { ... };
}
Expand description

Creates a newtype wrapper around a prost Message type that implements WireFormat.

ยงExamples

use jetstream::prelude::*;
use jetstream::prost_wireformat;
use prost::Message;

// Define a simple prost message for testing
#[derive(Clone, PartialEq, Message)]
pub struct TestMessage {
    #[prost(uint64, tag = "1")]
    pub id: u64,
    #[prost(string, tag = "2")]
    pub name: String,
    #[prost(bytes = "vec", tag = "3")]
    pub data: Vec<u8>,
}

// Public struct, private inner field and accessors
prost_wireformat!(pub TestMessage as MyMessage);

// Public struct with public inner field and accessors
prost_wireformat!(pub TestMessage as pub YourMessage);

// Crate-visible struct with public inner access
prost_wireformat!(pub(crate) TestMessage as pub OurMessage);

// With derives - adds Clone and Debug to the wrapper
prost_wireformat!(pub TestMessage as CloneableMessage, derive(Clone, Debug));