fn filter_thread_categories(map: BpfThreadMap) -> Result<BpfThreadMap, FilterError> {
    let (filters, invalid_filters): (BpfThreadMap, BpfThreadMap) = map
        .into_iter()
        .partition(|(k, _)| THREAD_CATEGORIES.contains(&k.as_str()));
    if !invalid_filters.is_empty() {
        // build the error message
        let mut thread_categories_string =
            invalid_filters
                .keys()
                .fold("".to_string(), |mut acc, elem| {
                    acc.push_str(elem);
                    acc.push(',');
                    acc
                });
        thread_categories_string.pop();
        return Err(FilterError::ThreadCategories(thread_categories_string));
    }

    for &category in THREAD_CATEGORIES.iter() {
        let category_string = category.to_string();
        if !filters.contains_key(&category_string) {
            return Err(FilterError::MissingThreadCategory(category_string));
        }
    }

    Ok(filters)
}
/// Return an error if the BpfThreadMap contains invalid thread categories.
Return an error if the BpfThreadMap contains invalid thread categories.
Return an error if the BpfThreadMap contains invalid thread categories .
fn filter_thread_categories(map: BpfThreadMap) -> Result<BpfThreadMap, FilterError> {
    let (filters, invalid_filters): (BpfThreadMap, BpfThreadMap) = map
        .into_iter()
        .partition(|(k, _)| THREAD_CATEGORIES.contains(&k.as_str()));
    if !invalid_filters.is_empty() {
        // build the error message
        let mut thread_categories_string =
            invalid_filters
                .keys()
                .fold("".to_string(), |mut acc, elem| {
                    acc.push_str(elem);
                    acc.push(',');
                    acc
                });
        thread_categories_string.pop();
        return Err(FilterError::ThreadCategories(thread_categories_string));
    }
    for &category in THREAD_CATEGORIES.iter() {
        let category_string = category.to_string();
        if !filters.contains_key(&category_string) {
            return Err(FilterError::MissingThreadCategory(category_string));
        }
    }
    Ok(filters)
}
fn filter_thread_categories ( map : BpfThreadMap ) -> Result < BpfThreadMap , FilterError > { let ( filters , invalid_filters ) : ( BpfThreadMap , BpfThreadMap ) = map . into_iter ( ) . partition ( | ( k , _ ) | THREAD_CATEGORIES . contains ( & k . as_str ( ) ) ) ; if ! invalid_filters . is_empty ( ) { // build the error message let mut thread_categories_string = invalid_filters . keys ( ) . fold ( " " . to_string ( ) , | mut acc , elem | { acc . push_str ( elem ) ; acc . push ( ',' ) ; acc } ) ; thread_categories_string . pop ( ) ; return Err ( FilterError :: ThreadCategories ( thread_categories_string ) ) ; } for & category in THREAD_CATEGORIES . iter ( ) { let category_string = category . to_string ( ) ; if ! filters . contains_key ( & category_string ) { return Err ( FilterError :: MissingThreadCategory ( category_string ) ) ; } } Ok ( filters ) }
Return an error if the BpfThreadMap contains invalid thread categories.
Return an error if the BpfThreadMap contains invalid thread categories .
map
BpfThreadMap
map
BpfThreadMap