Skip to main content

ContractEvent

Trait ContractEvent 

Source
pub trait ContractEvent {
    const TOPICS: &'static [&'static str];
}
Expand description

Declares the topics under which an event type is emitted.

Event authors implement this trait once per event struct, then list the types in the #[contract(events = [...])] module attribute. The macro reads TOPICS at compile time to populate the contract schema and to dispatch decode_event in the data driver.

A single struct may carry multiple topics — the topic conveys the operation while the struct carries the data — so TOPICS is a slice.

§Example

use dusk_forge::ContractEvent;

struct OwnershipTransferred;

impl ContractEvent for OwnershipTransferred {
    const TOPICS: &'static [&'static str] =
        &["ownership_transferred", "ownership_renounced"];
}

Required Associated Constants§

Source

const TOPICS: &'static [&'static str]

The topics under which this event type is emitted.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§