/// From a file path, gather the following data
/// - A `zettel_id` from the created timestamp
/// - The contents of file
/// - The title of the zettel (basename of filename)
/// - list of tags
/// - list of links
/// - list of headers
From a file path, gather the following data
A `zettel_id` from the created timestamp
The contents of file
The title of the zettel (basename of filename)
list of tags
list of links
list of headers
From a file path gather the following data A ` zettel_id ` from the created timestamp The contents of file The title of the zettel ( basename of filename ) list of tags list of links list of headers
fn gather_info(path: PathBuf, metadata: Metadata) -> Result<ParserGatherer, anyhow::Error> {
        let timestamp: chrono::DateTime<Utc> = metadata.created()?.into();
        let timestamp = timestamp.timestamp();
        let mut content = String::new();
        let mut file = File::open(&path)?;
        file.read_to_string(&mut content)?;
        let zettel_id = blake3::hash(&content.as_bytes())
            .to_hex()
            .as_str()
            .to_string();
        let tags = TAGS_REGEX
            .captures_iter(&content)
            .filter_map(|v| v.get(0))
            .map(|v| v.as_str().to_string())
            .collect::<Vec<_>>();
        let links = LINKS_REGEX
            .captures_iter(&content)
            .filter(|v| v.get(0).is_some())
            .map(|v| {
                if v.get(4).is_some() {
                    (
                        v.get(4).unwrap().as_str().to_string(),
                        v.get(4).unwrap().as_str().to_string(),
                    )
                } else {
                    (
                        v.get(1).unwrap().as_str().to_string(),
                        v.get(2).unwrap().as_str().to_string(),
                    )
                }
            })
            .collect::<Vec<_>>();
        let headers = HEADERS_REGEX
            .captures_iter(&content)
            .filter(|v| v.get(0).is_some())
            .map(|v| (v[1].len() as i32, v.get(2).unwrap().as_str().to_string()))
            .collect::<Vec<_>>();
        let title = headers
            .iter()
            .find(|h| h.0 == 1)
            .map(|v| v.1.clone())
            .unwrap_or_else(|| path.to_str().unwrap().to_string());
        Ok(ParserGatherer {
            text: content,
            path,
            timestamp,
            zettel_id,
            headers,
            tags,
            links,
            title,
        })
    }
fn gather_info ( path : PathBuf , metadata : Metadata ) -> Result < ParserGatherer , anyhow :: Error > { let timestamp : chrono :: DateTime < Utc > = metadata . created ( ) ? . into ( ) ; let timestamp = timestamp . timestamp ( ) ; let mut content = String :: new ( ) ; let mut file = File :: open ( & path ) ? ; file . read_to_string ( & mut content ) ? ; let zettel_id = blake3 :: hash ( & content . as_bytes ( ) ) . to_hex ( ) . as_str ( ) . to_string ( ) ; let tags = TAGS_REGEX . captures_iter ( & content ) . filter_map ( | v | v . get ( 0 ) ) . map ( | v | v . as_str ( ) . to_string ( ) ) . collect :: < Vec < _ > > ( ) ; let links = LINKS_REGEX . captures_iter ( & content ) . filter ( | v | v . get ( 0 ) . is_some ( ) ) . map ( | v | { if v . get ( 4 ) . is_some ( ) { ( v . get ( 4 ) . unwrap ( ) . as_str ( ) . to_string ( ) , v . get ( 4 ) . unwrap ( ) . as_str ( ) . to_string ( ) , ) } else { ( v . get ( 1 ) . unwrap ( ) . as_str ( ) . to_string ( ) , v . get ( 2 ) . unwrap ( ) . as_str ( ) . to_string ( ) , ) } } ) . collect :: < Vec < _ > > ( ) ; let headers = HEADERS_REGEX . captures_iter ( & content ) . filter ( | v | v . get ( 0 ) . is_some ( ) ) . map ( | v | ( v [ 1 ] . len ( ) as i32 , v . get ( 2 ) . unwrap ( ) . as_str ( ) . to_string ( ) ) ) . collect :: < Vec < _ > > ( ) ; let title = headers . iter ( ) . find ( | h | h . 0 == 1 ) . map ( | v | v . 1 . clone ( ) ) . unwrap_or_else ( | | path . to_str ( ) . unwrap ( ) . to_string ( ) ) ; Ok ( ParserGatherer { text : content , path , timestamp , zettel_id , headers , tags , links , title , } ) }
From a file path, gather the following data
 A `zettel_id` from the created timestamp
 The contents of file
 The title of the zettel (basename of filename)
 list of tags
 list of links
 list of headers
From a file path gather the following data A ` zettel_id ` from the created timestamp The contents of file The title of the zettel ( basename of filename ) list of tags list of links list of headers
path
PathBuf
metadata
Metadata