pub fn find_index(data: &[u8], name: &ArrayString64) -> Result<Option<usize>, ProgramError> {
        let rec_active = RefDB::get_active_records(data)?;
        if rec_active == 0 {
            return Ok(None);
        }
        let rec_num = RefDB::get_total_records(data)?;
        let rec_size = RefDB::get_record_size(data)?;
        let mut offset = Header::LEN;
        let mut checked = 0;
        for index in 0..rec_num {
            let (counter, rec_name) = RefDB::get_record_counter_and_name(data, offset)?;
            if counter > 0 {
                if rec_name == *name {
                    return Ok(Some(index));
                }
                checked += 1;
                if checked == rec_active {
                    return Ok(None);
                }
            }
            offset += rec_size;
        }
        Ok(None)
    }
/// Returns index of the record with the given name or None if not found
Returns index of the record with the given name or None if not found
Returns index of the record with the given name or None if not found
pub fn find_index(data: &[u8], name: &ArrayString64) -> Result<Option<usize>, ProgramError> {
        let rec_active = RefDB::get_active_records(data)?;
        if rec_active == 0 {
            return Ok(None);
        }
        let rec_num = RefDB::get_total_records(data)?;
        let rec_size = RefDB::get_record_size(data)?;
        let mut offset = Header::LEN;
        let mut checked = 0;
        for index in 0..rec_num {
            let (counter, rec_name) = RefDB::get_record_counter_and_name(data, offset)?;
            if counter > 0 {
                if rec_name == *name {
                    return Ok(Some(index));
                }
                checked += 1;
                if checked == rec_active {
                    return Ok(None);
                }
            }
            offset += rec_size;
        }
        Ok(None)
    }
pub fn find_index ( data : & [ u8 ] , name : & ArrayString64 ) -> Result < Option < usize > , ProgramError > { let rec_active = RefDB :: get_active_records ( data ) ? ; if rec_active == 0 { return Ok ( None ) ; } let rec_num = RefDB :: get_total_records ( data ) ? ; let rec_size = RefDB :: get_record_size ( data ) ? ; let mut offset = Header :: LEN ; let mut checked = 0 ; for index in 0 .. rec_num { let ( counter , rec_name ) = RefDB :: get_record_counter_and_name ( data , offset ) ? ; if counter > 0 { if rec_name == * name { return Ok ( Some ( index ) ) ; } checked += 1 ; if checked == rec_active { return Ok ( None ) ; } } offset += rec_size ; } Ok ( None ) }
Returns index of the record with the given name or None if not found
Returns index of the record with the given name or None if not found
data
&[u8]
name
&ArrayString64
data
&[u8]
name
&ArrayString64