carbon_name_service_decoder/accounts/
mod.rs1use crate::{NameServiceDecoder, PROGRAM_ID};
3
4#[cfg(feature = "postgres")]
5pub mod postgres;
6
7#[cfg(feature = "graphql")]
8pub mod graphql;
9
10pub mod name_record_header;
11
12#[derive(Debug, Clone, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
15pub enum NameServiceAccount {
16 NameRecordHeader(Box<name_record_header::NameRecordHeader>),
17}
18
19impl<'a> carbon_core::account::AccountDecoder<'a> for NameServiceDecoder {
20 type AccountType = NameServiceAccount;
21
22 fn decode_account(
23 &self,
24 account: &'a solana_account::Account,
25 ) -> Option<carbon_core::account::DecodedAccount<Self::AccountType>> {
26 if account.owner != PROGRAM_ID {
27 return None;
28 }
29
30 let data = account.data.as_slice();
31
32 {
33 if let Some(decoded) = name_record_header::NameRecordHeader::decode(data) {
34 return Some(carbon_core::account::DecodedAccount {
35 lamports: account.lamports,
36 data: NameServiceAccount::NameRecordHeader(Box::new(decoded)),
37 owner: account.owner,
38 executable: account.executable,
39 rent_epoch: account.rent_epoch,
40 });
41 }
42 }
43
44 None
45 }
46}