1use extism::{convert::Json, *};
2use fluentci_common::pkgx as common_pkgx;
3
4use crate::state::State;
5
6host_fn!(pub pkgx(user_data: State;) -> Json<Pkgx> {
7 let state = user_data.get()?;
8 let state = state.lock().unwrap();
9 let graph = state.graph.clone();
10 let pkgx = common_pkgx::pkgx(graph, true)?;
11 Ok(Json(pkgx))
12});
13
14host_fn!(pub with_packages(user_data: State; packages: Json<Vec<String>>) {
15 let state = user_data.get()?;
16 let state = state.lock().unwrap();
17 let graph = state.graph.clone();
18 let packages = packages.into_inner();
19 common_pkgx::with_packages(graph, packages)?;
20 Ok(())
21});