cloudevents::event

Trait EventBuilder

Source
pub trait EventBuilder
where Self: Clone + Sized + From<Event> + Default,
{ // Required methods fn new() -> Self; fn build(self) -> Result<Event, Error>; }
Expand description

Trait to implement a builder for Event:

use cloudevents::event::{EventBuilderV10, EventBuilder};
use chrono::Utc;
use url::Url;

let event = EventBuilderV10::new()
    .id("my_event.my_application")
    .source("http://localhost:8080")
    .ty("example.demo")
    .time(Utc::now())
    .build()
    .unwrap();

You can create an EventBuilder starting from an existing Event using the From trait. You can create a default EventBuilder setting default values for some attributes.

Required Methods§

Source

fn new() -> Self

Create a new empty builder

Source

fn build(self) -> Result<Event, Error>

Build Event

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl EventBuilder for cloudevents::event::EventBuilderV03

Source§

impl EventBuilder for cloudevents::event::EventBuilderV10