2023-09-24 21:09:40 +02:00
|
|
|
mod crunch;
|
|
|
|
|
|
|
|
use ::crunch::traits::{Deserializer, Event, EventInfo, Serializer};
|
2023-09-24 10:48:41 +02:00
|
|
|
|
|
|
|
struct MyEvent {}
|
|
|
|
|
|
|
|
impl Serializer for MyEvent {
|
2023-09-24 21:09:40 +02:00
|
|
|
fn serialize(&self) -> Result<Vec<u8>, ::crunch::errors::SerializeError> {
|
2023-09-24 10:48:41 +02:00
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Deserializer for MyEvent {
|
2023-09-24 21:09:40 +02:00
|
|
|
fn deserialize(_raw: Vec<u8>) -> Result<Self, ::crunch::errors::DeserializeError>
|
2023-09-24 10:48:41 +02:00
|
|
|
where
|
|
|
|
Self: Sized,
|
|
|
|
{
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Event for MyEvent {
|
2023-09-24 21:09:40 +02:00
|
|
|
fn event_info() -> ::crunch::traits::EventInfo {
|
2023-09-24 10:48:41 +02:00
|
|
|
EventInfo {
|
|
|
|
domain: "my-domain",
|
|
|
|
entity_type: "my-entity-type",
|
|
|
|
event_name: "my-event-name",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> anyhow::Result<()> {
|
2023-09-24 21:09:40 +02:00
|
|
|
crunch::basic::my_event::MyEvent {
|
|
|
|
name: "some-name".into(),
|
|
|
|
include: Some(crunch::basic::includes::my_include::MyInclude {
|
|
|
|
name: "some-name".into(),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
let crunch = ::crunch::builder::Builder::default().build()?;
|
2023-09-24 10:48:41 +02:00
|
|
|
|
|
|
|
crunch
|
|
|
|
.subscribe(|_item: MyEvent| async move { Ok(()) })
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
crunch.publish(MyEvent {}).await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|