From 8ce7c66a86df23a96b2a21bea72157fc12c91598 Mon Sep 17 00:00:00 2001 From: Evan Batsell Date: Tue, 10 Dec 2024 18:39:21 -0500 Subject: [PATCH] delete rando --- core/src/mint_entry_serde.rs | 83 ------------------------------------ 1 file changed, 83 deletions(-) delete mode 100644 core/src/mint_entry_serde.rs diff --git a/core/src/mint_entry_serde.rs b/core/src/mint_entry_serde.rs deleted file mode 100644 index f6a6ac0..0000000 --- a/core/src/mint_entry_serde.rs +++ /dev/null @@ -1,83 +0,0 @@ -// mint_entry_serde.rs -use std::{fmt, marker::PhantomData}; - -use serde::{ - de::{Error, SeqAccess, Visitor}, - ser::SerializeSeq, - Deserialize, Deserializer, Serialize, Serializer, -}; - -use crate::tracked_mints::MintEntry; - -// Helper struct for serialization -#[derive(Serialize, Deserialize)] -struct SerializableMintEntry { - st_mint: String, // Pubkey as base58 string - vault_index: u64, - #[serde(with = "serde_with::As::")] - reserved: [u8; 32], -} - -impl From<&MintEntry> for SerializableMintEntry { - fn from(entry: &MintEntry) -> Self { - Self { - st_mint: entry.st_mint.to_string(), - vault_index: entry.vault_index.into(), - reserved: entry.reserved, - } - } -} - -impl From for MintEntry { - fn from(entry: SerializableMintEntry) -> Self { - Self { - st_mint: entry.st_mint.parse().unwrap_or_default(), - vault_index: entry.vault_index.into(), - reserved: entry.reserved, - } - } -} -pub struct MintEntryArraySerializer; - -impl MintEntryArraySerializer { - pub fn serialize(entries: &[MintEntry; 64], serializer: S) -> Result - where - S: Serializer, - { - let mut seq = serializer.serialize_seq(Some(64))?; - for entry in entries.iter() { - seq.serialize_element(&SerializableMintEntry::from(entry))?; - } - seq.end() - } - - pub fn deserialize<'de, D>(deserializer: D) -> Result<[MintEntry; 64], D::Error> - where - D: Deserializer<'de>, - { - struct MintEntryArrayVisitor(PhantomData); - - impl<'de> Visitor<'de> for MintEntryArrayVisitor { - type Value = [MintEntry; 64]; - - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("an array of 64 MintEntry") - } - - fn visit_seq(self, mut seq: A) -> Result - where - A: SeqAccess<'de>, - { - let mut entries = [MintEntry::default(); 64]; - for i in 0..64 { - entries[i] = seq - .next_element()? - .ok_or_else(|| Error::invalid_length(i, &self))?; - } - Ok(entries) - } - } - - deserializer.deserialize_seq(MintEntryArrayVisitor(PhantomData)) - } -}