gmsol_decode/value/
utils.rs1use solana_sdk::pubkey::Pubkey;
2
3use crate::Decoder;
4
5pub struct OwnedDataDecoder<'a>(&'a Pubkey, &'a [u8]);
7
8impl<'a> OwnedDataDecoder<'a> {
9 pub fn new(program_id: &'a Pubkey, data: &'a [u8]) -> Self {
11 Self(program_id, data)
12 }
13}
14
15impl Decoder for OwnedDataDecoder<'_> {
16 fn decode_account<V>(&self, _visitor: V) -> Result<V::Value, crate::DecodeError>
17 where
18 V: crate::Visitor,
19 {
20 Err(crate::DecodeError::InvalidType(
21 "Expecting `Account` but found `Data`".to_string(),
22 ))
23 }
24
25 fn decode_transaction<V>(&self, _visitor: V) -> Result<V::Value, crate::DecodeError>
26 where
27 V: crate::Visitor,
28 {
29 Err(crate::DecodeError::InvalidType(
30 "Expecting `Transaction` but found `Data`".to_string(),
31 ))
32 }
33
34 fn decode_anchor_cpi_events<V>(&self, _visitor: V) -> Result<V::Value, crate::DecodeError>
35 where
36 V: crate::Visitor,
37 {
38 Err(crate::DecodeError::InvalidType(
39 "Expecting `AnchorCPIEvents` but found `Data`".to_string(),
40 ))
41 }
42
43 fn decode_owned_data<V>(&self, visitor: V) -> Result<V::Value, crate::DecodeError>
44 where
45 V: crate::Visitor,
46 {
47 visitor.visit_owned_data(self.0, self.1)
48 }
49
50 fn decode_bytes<V>(&self, visitor: V) -> Result<V::Value, crate::DecodeError>
51 where
52 V: crate::Visitor,
53 {
54 visitor.visit_bytes(self.1)
55 }
56}