use {
crate::{list::ListView, pod_length::PodLength},
bytemuck::Pod,
solana_program_error::ProgramError,
std::ops::Deref,
};
pub trait List: Deref<Target = [Self::Item]> {
type Item: Pod;
type Length: PodLength;
fn capacity(&self) -> usize;
fn bytes_used(&self) -> Result<usize, ProgramError> {
ListView::<Self::Item, Self::Length>::size_of(self.len())
}
fn bytes_allocated(&self) -> Result<usize, ProgramError> {
ListView::<Self::Item, Self::Length>::size_of(self.capacity())
}
}