gmsol_decode/decode/
visitor.rs1use anchor_lang::solana_program::pubkey::Pubkey;
2
3use crate::{
4 decoder::{
5 account_access::AccountAccess, cpi_event_access::AnchorCPIEventsAccess,
6 transaction_access::TransactionAccess,
7 },
8 error::DecodeError,
9};
10
11pub trait Visitor: Sized {
13 type Value;
15
16 fn visit_account(self, account: impl AccountAccess) -> Result<Self::Value, DecodeError> {
18 _ = account;
19 Err(DecodeError::InvalidType(
20 "Unexpected type `Account`".to_string(),
21 ))
22 }
23
24 fn visit_transaction(
26 self,
27 transaction: impl TransactionAccess,
28 ) -> Result<Self::Value, DecodeError> {
29 _ = transaction;
30 Err(DecodeError::InvalidType(
31 "Unexpected type `Transaction`".to_string(),
32 ))
33 }
34
35 fn visit_anchor_cpi_events<'a>(
37 self,
38 events: impl AnchorCPIEventsAccess<'a>,
39 ) -> Result<Self::Value, DecodeError> {
40 _ = events;
41 Err(DecodeError::InvalidType(
42 "Unexpected type `AnchorCPIEvents`".to_string(),
43 ))
44 }
45
46 fn visit_owned_data(
50 self,
51 program_id: &Pubkey,
52 data: &[u8],
53 ) -> Result<Self::Value, DecodeError> {
54 _ = program_id;
55 _ = data;
56 Err(DecodeError::InvalidType(
57 "Unexpected type `OwnedData`".to_string(),
58 ))
59 }
60
61 fn visit_bytes(self, data: &[u8]) -> Result<Self::Value, DecodeError> {
63 _ = data;
64 Err(DecodeError::InvalidType(
65 "Unexpected type `Bytes`".to_string(),
66 ))
67 }
68}