use std::io; use std::path::Path; use async_std::prelude::*; use async_std::fs::read_dir; use git2::Repository; pub struct State { pub data: Vec, } impl State { pub async fn discover(root: impl AsRef) -> io::Result { let root = root.as_ref(); let dir = read_dir(root).await?; let data = dir .filter_map(|subdir| { subdir.ok().and_then(|subdir| Repository::open_bare(&subdir.path()).ok()) }) .collect().await; Ok(Self { data }) } }