#[entity_trait_impl]Expand description
Attribute macro for trait capability impl blocks.
Each async fn annotated with #[rpc], #[workflow], or #[activity] becomes
an RPC handler that can be called on entities using this trait.
§Attributes
#[entity_trait_impl]— default crate path#[entity_trait_impl(krate = "crate")]— for internal use within cruster
§Method Annotations
#[rpc]— Read-only RPC handler (no state mutation)#[workflow]— Durable workflow handler (state mutations)#[activity]— Durable activity handler (external side effects)
§Visibility Annotations
#[public]— Callable by external clients (default for#[rpc]and#[workflow])#[protected]— Callable only by other entities (entity-to-entity)#[private]— Internal only (default for#[activity])
§Example
#[entity_trait_impl]
#[state(AuditLog)]
impl Auditable {
fn init(&self) -> Result<AuditLog, ClusterError> {
Ok(AuditLog::default())
}
#[activity]
#[protected]
async fn log_action(&self, action: String) -> Result<(), ClusterError> {
let mut state = self.state_mut().await;
state.log(action);
Ok(())
}
#[rpc]
async fn get_log(&self) -> Result<Vec<String>, ClusterError> {
Ok(self.state().entries.clone())
}
}