gmsol_decode/decoder/cpi_event_access.rs
1use solana_sdk::signature::Signature;
2
3use crate::{decode::Decode, error::DecodeError};
4
5/// Access a Anchor CPI Event.
6pub trait AnchorCPIEventsAccess<'a> {
7 /// Get the slot of the transaction where the events were generated.
8 fn slot(&self) -> Result<u64, DecodeError>;
9
10 /// Get the index in the block of the transaction where the events were generated.
11 ///
12 /// ## Note
13 /// The `index` may be `None` because for old transaction info format,
14 /// the `index` of the transaction is not provided.
15 fn index(&self) -> Result<Option<usize>, DecodeError>;
16
17 /// Get the signature of the transaction where the events were generated.
18 fn signature(&self) -> Result<&Signature, DecodeError>;
19
20 /// Decode next event.
21 fn next_event<T>(&mut self) -> Result<Option<T>, DecodeError>
22 where
23 T: Decode;
24}