use std::ops::Add; use derive_deref::{Deref, DerefMut}; use serde::Serialize; use vecdb::{CheckedSub, Printable, StoredCompressed}; use zerocopy_derive::{FromBytes, Immutable, IntoBytes, KnownLayout}; use crate::TypeIndex; #[derive( Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Deref, DerefMut, Default, FromBytes, Immutable, IntoBytes, KnownLayout, Serialize, StoredCompressed, )] pub struct UnknownOutputIndex(TypeIndex); impl From for UnknownOutputIndex { fn from(value: TypeIndex) -> Self { Self(value) } } impl From for u64 { fn from(value: UnknownOutputIndex) -> Self { Self::from(*value) } } impl From for usize { fn from(value: UnknownOutputIndex) -> Self { Self::from(*value) } } impl From for UnknownOutputIndex { fn from(value: usize) -> Self { Self(TypeIndex::from(value)) } } impl Add for UnknownOutputIndex { type Output = Self; fn add(self, rhs: usize) -> Self::Output { Self(*self + rhs) } } impl CheckedSub for UnknownOutputIndex { fn checked_sub(self, rhs: Self) -> Option { self.0.checked_sub(rhs.0).map(Self) } } impl Printable for UnknownOutputIndex { fn to_string() -> &'static str { "unknownoutputindex" } fn to_possible_strings() -> &'static [&'static str] { &["unknownout", "unknownoutputindex"] } }