iota_json_rpc_types/
iota_indexer.rs1use std::collections::BTreeMap;
5
6use iota_names::registry::NameRecord;
7use iota_types::base_types::{IotaAddress, ObjectID};
8use schemars::JsonSchema;
9use serde::{Deserialize, Serialize};
10use serde_with::serde_as;
11
12#[serde_as]
14#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
15#[serde(rename_all = "camelCase")]
16pub struct IotaNameRecord {
17 pub nft_id: ObjectID,
25 pub expiration_timestamp_ms: u64,
27 pub target_address: Option<IotaAddress>,
29 pub data: BTreeMap<String, String>,
31}
32
33impl From<NameRecord> for IotaNameRecord {
34 fn from(record: NameRecord) -> Self {
35 Self {
36 nft_id: record.nft_id.bytes,
37 expiration_timestamp_ms: record.expiration_timestamp_ms,
38 target_address: record.target_address,
39 data: record
40 .data
41 .contents
42 .into_iter()
43 .map(|entry| (entry.key.to_string(), entry.value.to_string()))
44 .collect(),
45 }
46 }
47}