pub trait MessageInfo {
const NAME: &'static str;
const DESCRIPTION: Option<&'static str> = None;
}Expand description
Metadata about a message type, used to name and describe it in an AsyncAPI document.
Derive with #[derive(MessageInfo)] (requires the macros feature): the derive uses the type’s
name as NAME and its doc comment as DESCRIPTION.
§Examples
use ruststream::memory::prelude::*;
use serde::Deserialize;
/// An order a customer placed.
#[derive(Deserialize)]
struct OrderPlacedV2 {
id: u64,
}
// The component keeps the name the contract was published under, whatever the Rust type is
// called now.
impl MessageInfo for OrderPlacedV2 {
const NAME: &'static str = "OrderPlaced";
const DESCRIPTION: Option<&'static str> = Some("An order a customer placed.");
}
#[subscriber("orders")]
async fn accept(order: &OrderPlacedV2) -> HandlerOutcome {
tracing::info!(order.id, "accepted");
HandlerOutcome::ack()
}
fn app() -> RustStream {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(MemoryBroker::new(), |b| {
b.include(accept);
})
}Required Associated Constants§
Provided Associated Constants§
Sourceconst DESCRIPTION: Option<&'static str> = None
const DESCRIPTION: Option<&'static str> = None
An optional description, typically from the type’s doc comment.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".