mod archive; mod posts; use compute_graph::{ builder::GraphBuilder, rule::{Input, InputVisitable, Rule}, AsyncGraph, }; pub async fn generate() -> anyhow::Result<()> { std::fs::create_dir_all("out").expect("creating output dir"); // TODO: file watching let mut graph = make_graph()?; graph.evaluate_async().await; println!("{}", graph.as_dot_string()); Ok(()) } fn make_graph() -> anyhow::Result> { let mut builder = GraphBuilder::::new_async(); let posts = posts::list_post_files()?; let posts = posts .into_iter() .map(|path| builder.add_rule(posts::ParsePost(path))) .collect::>(); // let post_metadatas = posts // .iter() // .map(|post| builder.add_rule(posts::ExtractMetadata(post.clone()))) // .collect::>(); let archive = archive::make_graph(&mut builder, &posts); builder.set_output(Output { archive }); Ok(builder.build()?) } type GraphOutput = (); #[derive(InputVisitable)] struct Output { archive: Input<()>, } impl Rule for Output { type Output = GraphOutput; fn evaluate(&mut self) -> Self::Output { () } }