spl_list_view/
list_trait.rs1use {
2 crate::ListView, bytemuck::Pod, core::ops::Deref, solana_program_error::ProgramError,
3 spl_pod::pod_length::PodLength,
4};
5
6pub trait List: Deref<Target = [Self::Item]> {
9 type Item: Pod;
11 type Length: PodLength;
13
14 fn capacity(&self) -> usize;
16
17 fn bytes_used(&self) -> Result<usize, ProgramError> {
19 ListView::<Self::Item, Self::Length>::size_of(self.len())
20 }
21
22 fn bytes_allocated(&self) -> Result<usize, ProgramError> {
24 ListView::<Self::Item, Self::Length>::size_of(self.capacity())
25 }
26}