Skip to main content

Rust SDK API Reference / Non-blocking APIs / Record V1 / get_record

Function: get_record()

pub async fn get_record(
rpc_client: &RpcClient,
domain: &str,
record: Record,
) -> Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>

Defined in: rust-crates/sns-sdk/src/non_blocking/record_v1.rs:11

Validates the full domain's supported TLD, derives the V1 record address, and reads the account through RPC. The byte vector excludes the NameRecordHeader; deserialize it with the V1 record helper.

Parameters

ParameterTypeDescription
rpc_client&RpcClientNon-blocking Solana RPC client.
domain&strFull supported .sns or .sol domain name.
recordRecordLegacy record type to retrieve.

Returns

Result<Option<(NameRecordHeader, Vec<u8>)>, SnsError>. Some contains the account header and payload; None means the record account does not exist.

Errors

  • SnsError::UnsupportedTld when domain is bare or has an unsupported suffix.
  • SnsError::InvalidNameAccountData when a present record account is invalid.
  • SnsError::SolanaClient when a TLD or record RPC request fails.

Example

use sns_sdk::{non_blocking::record_v1::get_record, record::Record};

if let Some((_header, payload)) = get_record(&client, "bonfida.sns", Record::Url).await? {
println!("record bytes: {}", payload.len());
}