macro_rules! topic {
($tyname:ident, $msg:tt $(< $msg_lt:lifetime >)? $(,)?) => { ... };
($tyname:ident, $msg:tt $(< $msg_lt:lifetime >)?, $path:expr $(,)?) => { ... };
}Expand description
ยงTopic macro
Used to define a single Topic marker type that implements the Topic trait.
Borrowed types may contain lifetimes, but only as types with lifetimes, not
direct references. This means we can accept Borrowed<'a> as a type but not
&'a str.
use ergot::topic;
#[derive(Schema, Debug, PartialEq, Serialize, Deserialize)]
pub struct Stir<'a> {
s: &'a str,
}
#[derive(Debug, Serialize, Deserialize, Schema)]
pub struct Message1 {
a: u8,
b: u64,
}
// owned topic
topic!(Topic1, Message1, "topic/1");
// borrowed topic
topic!(Topic2, Stir<'a>, "topic/2");If the path is omitted, the type name is used instead.