eth_avatars/modules/ethereum/
nft.rs1use serde::Deserialize;
2
3use crate::{FetchError, Resource, resource::Decoder};
4
5#[derive(Deserialize)]
6pub struct NftMetadata {
7 pub image: Option<String>,
8}
9
10pub struct NftMetadataDecoder;
11
12impl Decoder for NftMetadataDecoder {
13 fn decode(&self, bytes: Vec<u8>) -> Result<Resource, FetchError> {
14 serde_json::from_slice::<NftMetadata>(&bytes)
15 .map_err(|_| FetchError::Unsupported)
16 .and_then(|x| x.image.ok_or(FetchError::Unsupported))
17 .and_then(|x| x.parse().map_err(Into::into))
18 }
19}