spl_pod/list/
list_trait.rs1use {
2 crate::{list::ListView, pod_length::PodLength},
3 bytemuck::Pod,
4 solana_program_error::ProgramError,
5 std::ops::Deref,
6};
7
8pub trait List: Deref<Target = [Self::Item]> {
11 type Item: Pod;
13 type Length: PodLength;
15
16 fn capacity(&self) -> usize;
18
19 fn bytes_used(&self) -> Result<usize, ProgramError> {
21 ListView::<Self::Item, Self::Length>::size_of(self.len())
22 }
23
24 fn bytes_allocated(&self) -> Result<usize, ProgramError> {
26 ListView::<Self::Item, Self::Length>::size_of(self.capacity())
27 }
28}