gmsol_decode/decode/
visitor.rs1use anchor_lang::solana_program::pubkey::Pubkey;
2
3use crate::{
4 decoder::{account_access::AccountAccess, cpi_event_access::AnchorCPIEventsAccess},
5 error::DecodeError,
6};
7
8pub trait Visitor: Sized {
10 type Value;
12
13 fn visit_account(self, account: impl AccountAccess) -> Result<Self::Value, DecodeError> {
15 _ = account;
16 Err(DecodeError::InvalidType(
17 "Unexpected type `Account`".to_string(),
18 ))
19 }
20
21 fn visit_anchor_cpi_events<'a>(
23 self,
24 events: impl AnchorCPIEventsAccess<'a>,
25 ) -> Result<Self::Value, DecodeError> {
26 _ = events;
27 Err(DecodeError::InvalidType(
28 "Unexpected type `AnchorCPIEvents`".to_string(),
29 ))
30 }
31
32 fn visit_owned_data(
36 self,
37 program_id: &Pubkey,
38 data: &[u8],
39 ) -> Result<Self::Value, DecodeError> {
40 _ = program_id;
41 _ = data;
42 Err(DecodeError::InvalidType(
43 "Unexpected type `OwnedData`".to_string(),
44 ))
45 }
46
47 fn visit_bytes(self, data: &[u8]) -> Result<Self::Value, DecodeError> {
49 _ = data;
50 Err(DecodeError::InvalidType(
51 "Unexpected type `Bytes`".to_string(),
52 ))
53 }
54}