xrpl_std/core/ledger_objects/
nft.rs

1use crate::core::types::account_id::AccountID;
2use crate::core::types::contract_data::XRPL_CONTRACT_DATA_SIZE;
3use crate::host;
4use crate::types::NFT;
5use host::{Error, Result, Result::Ok};
6
7// TODO: Add documentation and examples.
8
9// TODO: Define an Nft struct
10pub fn get_nft(owner: &AccountID, nft: &NFT) -> Result<[u8; XRPL_CONTRACT_DATA_SIZE]> {
11    let mut data = [0u8; XRPL_CONTRACT_DATA_SIZE];
12    let result_code = unsafe {
13        host::get_nft(
14            owner.0.as_ptr(),
15            owner.0.len(),
16            nft.as_ptr(),
17            nft.len(),
18            data.as_mut_ptr(),
19            data.len(),
20        )
21    };
22
23    match result_code {
24        code if code > 0 => Ok(data),
25        code => Result::Err(Error::from_code(code)),
26    }
27}