rialo-rex-processor-interface 0.4.0-alpha.1

Instructions and constructors for the program processing REX updates from validators
Documentation
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//! Events emitted by the REX Processor program.
//!
//! This module defines the events that are emitted when REX reports are stored.
//! Subscribers can use these events to react to REX data updates without relying
//! on aggregator programs.

use rialo_events_core::derive::RialoEvent;
use rialo_types::RexId;
use serde::Serialize;

/// Event emitted when an REX 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 REX data updates.
///
/// # Topic Format
///
/// The event uses a parameterized topic with the rex_id as the dynamic parameter.
/// Topic format: `rialo_rex_processor_interface::event::RexReportEvent::{rex_id}`
/// where `rex_id` is in the string format `{nonce}:{creator}`.
///
/// # Example Usage
///
/// Subscribers can:
/// 1. Create an event instance: `let event = RexReportEvent::new(rex_id);`
/// 2. Get the instance topic: `let topic = event.instance_topic();`
/// 3. Subscribe to the topic for a specific REX request
/// 4. Use `derive_report_address()` to get the report PDA from the rex_id
/// 5. Read the full `RexReport` data from the PDA
#[derive(Debug, Default, Clone, Serialize, RialoEvent)]
pub struct RexReportEvent {
    /// The REX ID - marked with #\[topic] to create instance-specific topics
    #[topic]
    pub rex_id: RexId,
}

impl RexReportEvent {
    /// Creates a new `RexReportEvent`.
    ///
    /// # Arguments
    ///
    /// * `rex_id` - The REX ID
    pub fn new(rex_id: RexId) -> Self {
        Self { rex_id }
    }
}