pub async fn find_files_with_extension(folder_path: &str, opts: &DirLoaderOptions) -> Vec<String> {
    let mut matching_files = Vec::new();
    let folder_path = Path::new(folder_path);
    let mut all_files: Vec<String> = Vec::new();

    list_files_in_path(folder_path, &mut all_files, &opts.clone())
        .await
        .unwrap();

    for file_name in all_files {
        let path_str = file_name.clone();

        // check if the file has the required extension
        if let Some(suffixes) = &opts.suffixes {
            let mut has_suffix = false;
            for suffix in suffixes {
                if path_str.ends_with(suffix) {
                    has_suffix = true;
                    break;
                }
            }
            if !has_suffix {
                continue;
            }
        }

        if opts
            .path_filter
            .as_ref()
            .map_or(false, |f| f.0(&Path::new(&file_name)))
        {
            continue; // Skip this path if the filter returns true
        }

        // check if the file matches the glob pattern
        if let Some(glob_pattern) = &opts.glob {
            let glob = glob::Pattern::new(glob_pattern).unwrap();
            if !glob.matches(&path_str) {
                continue;
            }
        }

        matching_files.push(path_str);
    }

    matching_files
}
Find files in a directory that match the given options
src/document_loaders/dir_loader.rs