pub struct OracleReportEvent {
pub oracle_id: OracleId,
}Expand description
Event emitted when an oracle report is stored.
This event is emitted after a report is successfully written to the report PDA. Subscribers can listen to this event to react to oracle data updates.
§Topic Format
The event uses a parameterized topic with the oracle_id as the dynamic parameter.
Topic format: rialo_oracle_processor_interface::event::OracleReportEvent::{oracle_id}
where oracle_id is in the string format {nonce}:{creator}.
§Example Usage
Subscribers can:
- Create an event instance:
let event = OracleReportEvent::new(oracle_id); - Get the instance topic:
let topic = event.instance_topic(); - Subscribe to the topic for a specific oracle
- Use
derive_report_address()to get the report PDA from the oracle_id - Read the full
OracleReportdata from the PDA
Fields§
§oracle_id: OracleIdThe oracle ID - marked with #[topic] to create instance-specific topics
Implementations§
Source§impl OracleReportEvent
impl OracleReportEvent
Sourcepub fn to_attribute_map(&self) -> AttributeMap<String, AttributeValue>
pub fn to_attribute_map(&self) -> AttributeMap<String, AttributeValue>
Converts this struct to an AttributeMap
This method provides a convenient way to convert the struct instance into an AttributeMap without explicitly using the From trait.
§Returns
An AttributeMap representation of this struct with all fields as attributes.
Sourcepub fn topic() -> &'static str
pub fn topic() -> &'static str
Returns the event topic as a string
The topic is constructed from the module path and struct name, creating a unique identifier for this event type.
§Returns
A static string representing this event’s topic.
Sourcepub fn emit(
&self,
program_id: &Pubkey,
accounts: &[AccountInfo<'_>],
) -> ProgramResult
pub fn emit( &self, program_id: &Pubkey, accounts: &[AccountInfo<'_>], ) -> ProgramResult
Emits this event using the provided program ID (legacy method)
This method converts the struct to an AttributeMap and emits it through the Rialo event system. The topic is extracted from the AttributeMap’s “topic” field.
§Arguments
program_id- The Solana program ID to associate with this eventaccounts- The accounts required for event emission
§Returns
A ProgramResult indicating success or failure of the event emission.
Sourcepub fn emit_with_topic(
&self,
topic: &str,
program_id: &Pubkey,
accounts: &[AccountInfo<'_>],
) -> ProgramResult
pub fn emit_with_topic( &self, topic: &str, program_id: &Pubkey, accounts: &[AccountInfo<'_>], ) -> ProgramResult
Emits this event using the provided program ID with a specific topic
This method converts the struct to an AttributeMap and emits it through the Rialo event system using the provided topic instead of extracting it from the AttributeMap.
§Arguments
topic- The topic identifier for the eventprogram_id- The Solana program ID to associate with this eventaccounts- The accounts required for event emission
§Returns
A ProgramResult indicating success or failure of the event emission.
Sourcepub fn initialize_storage(
&self,
program_id: &Pubkey,
accounts: &[AccountInfo<'_>],
) -> ProgramResult
pub fn initialize_storage( &self, program_id: &Pubkey, accounts: &[AccountInfo<'_>], ) -> ProgramResult
Initializes storage for this event type (legacy method)
This method sets up the necessary storage for this event type in the Rialo event system. The topic is extracted from the AttributeMap’s “topic” field. It should be called before emitting events of this type.
§Arguments
program_id- The Solana program ID to associate with this event typeaccounts- The accounts required for storage initialization
§Returns
A ProgramResult indicating success or failure of the storage initialization.
Sourcepub fn initialize_storage_with_topic(
&self,
topic: &str,
program_id: &Pubkey,
accounts: &[AccountInfo<'_>],
) -> ProgramResult
pub fn initialize_storage_with_topic( &self, topic: &str, program_id: &Pubkey, accounts: &[AccountInfo<'_>], ) -> ProgramResult
Initializes storage for this event type with a specific topic
This method sets up the necessary storage for this event type in the Rialo event system using the provided topic instead of extracting it from the AttributeMap. It should be called before emitting events of this type.
§Arguments
topic- The topic identifier for the eventprogram_id- The Solana program ID to associate with this event typeaccounts- The accounts required for storage initialization
§Returns
A ProgramResult indicating success or failure of the storage initialization.
Sourcepub fn instance_topic(&self) -> String
pub fn instance_topic(&self) -> String
Returns the instance-specific topic for this event
This topic includes the dynamic parameter from the #[topic] field, creating a unique topic for each instance (e.g., per oracle).
§Returns
A string in the format: {base_topic}::{topic_field_value}
Sourcepub fn to_attribute_map_with_dynamic_topic(
&self,
) -> AttributeMap<String, AttributeValue>
pub fn to_attribute_map_with_dynamic_topic( &self, ) -> AttributeMap<String, AttributeValue>
Converts this struct to an AttributeMap with the dynamic topic
This method is a convenience wrapper that converts the struct to an AttributeMap and overrides the “topic” key with the instance-specific topic.
§Returns
An AttributeMap with the dynamic topic from instance_topic().
Trait Implementations§
Source§impl Clone for OracleReportEvent
impl Clone for OracleReportEvent
Source§fn clone(&self) -> OracleReportEvent
fn clone(&self) -> OracleReportEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more