2025-02-23 16:10:21 -05:00
|
|
|
use polariton_server::operations::SimpleFunc;
|
2025-03-08 17:16:02 -05:00
|
|
|
use polariton::{operation::{Dict, ParameterTable, Typed}, serdes::TypePrefix};
|
2025-03-30 16:22:25 -04:00
|
|
|
use rc_core::ConfigProvider;
|
2025-02-23 16:10:21 -05:00
|
|
|
|
|
|
|
|
const PARAM_KEY: u8 = 16;
|
|
|
|
|
|
2025-03-30 16:22:25 -04:00
|
|
|
pub(super) fn cube_inv_provider(cubes: &rc_core::ConfigImpl) -> SimpleFunc<16, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
|
|
|
|
|
let cube_ids = <rc_core::ConfigImpl as ConfigProvider<()>>::ids(cubes);
|
2025-03-15 11:03:35 -04:00
|
|
|
SimpleFunc::new(move |params, _| {
|
2025-02-23 16:10:21 -05:00
|
|
|
let mut params = params.to_dict();
|
|
|
|
|
params.insert(PARAM_KEY, Typed::Dict(Dict {
|
2025-03-08 17:16:02 -05:00
|
|
|
key_ty: TypePrefix::Int, // int
|
|
|
|
|
val_ty: TypePrefix::Int, // int
|
2025-03-15 11:03:35 -04:00
|
|
|
items: cube_ids.iter().map(|id| (Typed::Int(*id as _), Typed::Int(1))).collect()}));
|
2025-02-23 16:10:21 -05:00
|
|
|
Ok(params.into())
|
|
|
|
|
})
|
|
|
|
|
}
|