gmsol_decode/decoder/
account_access.rs

1use solana_sdk::pubkey::Pubkey;
2
3use super::DecodeError;
4
5/// Access an account info.
6pub trait AccountAccess {
7    /// Get the owner of the account.
8    fn owner(&self) -> Result<Pubkey, DecodeError>;
9
10    /// Get the pubkey of the account.
11    fn pubkey(&self) -> Result<Pubkey, DecodeError>;
12
13    /// Get the lamports of the account.
14    fn lamports(&self) -> Result<u64, DecodeError>;
15
16    /// Get the account data.
17    fn data(&self) -> Result<&[u8], DecodeError>;
18
19    /// Get the slot at which the account data was updated.
20    fn slot(&self) -> Result<u64, DecodeError>;
21}
22
23impl<A: AccountAccess> AccountAccess for &A {
24    fn owner(&self) -> Result<Pubkey, DecodeError> {
25        (**self).owner()
26    }
27
28    fn pubkey(&self) -> Result<Pubkey, DecodeError> {
29        (**self).pubkey()
30    }
31
32    fn lamports(&self) -> Result<u64, DecodeError> {
33        (**self).lamports()
34    }
35
36    fn data(&self) -> Result<&[u8], DecodeError> {
37        (**self).data()
38    }
39
40    fn slot(&self) -> Result<u64, DecodeError> {
41        (**self).slot()
42    }
43}