Skip to main content

projection

Attribute Macro projection 

Source
#[projection]
Expand description

Adds a cursor: String field and implements ProjectionCursor.

This attribute macro transforms a struct to track its position in the event stream. It automatically adds a cursor field and implements the ProjectionCursor trait.

§Generated Code

  • Adds pub cursor: String field
  • Adds Default and Clone derives (preserves existing derives)
  • Implements ProjectionCursor trait

§Additional Derives

Pass additional derives as arguments:

#[evento::projection(serde::Serialize)]
pub struct MyView { ... }

§Example

#[evento::projection]
#[derive(Debug)]
pub struct MyStruct {
    pub id: String,
    pub name: String,
}

// Generates:
// #[derive(Default, Clone, Debug)]
// pub struct MyStruct {
//     pub id: String,
//     pub name: String,
//     pub cursor: String,
// }
//
// impl evento::ProjectionCursor for MyStruct { ... }