pub fn read_all(data: &[u8]) -> Result<Vec<Record>, ProgramError> {
        let rec_num = RefDB::get_total_records(data)?;
        let active_rec = RefDB::get_active_records(data)?;
        let mut vec: Vec<Record> = vec![];
        if active_rec == 0 {
            return Ok(vec);
        }
        for i in 0..rec_num {
            if let Some(rec) = RefDB::read_at(data, i)? {
                vec.push(rec);
                if vec.len() == active_rec {
                    return Ok(vec);
                }
            }
        }
        Err(ProgramError::InvalidAccountData)
    }
/// Returns all active records in the storage
Returns all active records in the storage
Returns all active records in the storage
pub fn read_all(data: &[u8]) -> Result<Vec<Record>, ProgramError> {
        let rec_num = RefDB::get_total_records(data)?;
        let active_rec = RefDB::get_active_records(data)?;
        let mut vec: Vec<Record> = vec![];
        if active_rec == 0 {
            return Ok(vec);
        }
        for i in 0..rec_num {
            if let Some(rec) = RefDB::read_at(data, i)? {
                vec.push(rec);
                if vec.len() == active_rec {
                    return Ok(vec);
                }
            }
        }
        Err(ProgramError::InvalidAccountData)
    }
pub fn read_all ( data : & [ u8 ] ) -> Result < Vec < Record > , ProgramError > { let rec_num = RefDB :: get_total_records ( data ) ? ; let active_rec = RefDB :: get_active_records ( data ) ? ; let mut vec : Vec < Record > = vec ! [ ] ; if active_rec == 0 { return Ok ( vec ) ; } for i in 0 .. rec_num { if let Some ( rec ) = RefDB :: read_at ( data , i ) ? { vec . push ( rec ) ; if vec . len ( ) == active_rec { return Ok ( vec ) ; } } } Err ( ProgramError :: InvalidAccountData ) }
Returns all active records in the storage
Returns all active records in the storage
data
&[u8]
data
&[u8]