tag.rs
1 use candid::{CandidType, Decode, Deserialize, Encode}; 2 use ic_stable_structures::{storable::Bound, Storable}; 3 use std::borrow::Cow; 4 5 #[derive(CandidType, Deserialize, Debug, Clone)] 6 pub struct TagData { 7 pub tagged_items: Vec<u128>, 8 pub tagged_markets: Vec<u128>, 9 } 10 11 impl Storable for TagData { 12 fn to_bytes(&self) -> std::borrow::Cow<[u8]> { 13 Cow::Owned(Encode!(self).unwrap()) 14 } 15 16 fn from_bytes(bytes: std::borrow::Cow<[u8]>) -> Self { 17 Decode!(bytes.as_ref(), Self).unwrap() 18 } 19 20 const BOUND: Bound = Bound::Unbounded; 21 }