2025-05-11 12:09:23 -04:00
|
|
|
use polariton::operation::{ParameterTable, OperationResponse};
|
|
|
|
|
|
|
|
|
|
const CODE: u8 = 1;
|
2025-02-23 16:10:21 -05:00
|
|
|
|
|
|
|
|
const PARAM_KEY: u8 = 1;
|
|
|
|
|
|
2025-06-03 21:09:03 -04:00
|
|
|
pub(super) fn garage_upgrades_provider(conf: &oj_rc_core::ConfigImpl) -> GarageUpgradesProvider {
|
2025-05-11 12:09:23 -04:00
|
|
|
GarageUpgradesProvider {
|
2026-01-13 17:50:40 -05:00
|
|
|
upgrades: <oj_rc_core::ConfigImpl as oj_rc_core::ConfigProvider<()>>::garage_upgrades(conf),
|
2025-05-11 12:09:23 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct GarageUpgradesProvider {
|
2025-06-03 21:09:03 -04:00
|
|
|
upgrades: oj_rc_core::persist::config::GarageUpgrades,
|
2025-05-11 12:09:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl GarageUpgradesProvider {
|
|
|
|
|
async fn do_handling(&self, params: ParameterTable) -> Result<ParameterTable, i16> {
|
2025-02-23 16:10:21 -05:00
|
|
|
let mut params = params.to_dict();
|
2025-05-11 12:09:23 -04:00
|
|
|
params.insert(PARAM_KEY, self.upgrades.slot_upgrades());
|
2025-02-23 16:10:21 -05:00
|
|
|
Ok(params.into())
|
2025-05-11 12:09:23 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
|
impl polariton_server::operations::Operation<()> for GarageUpgradesProvider {
|
|
|
|
|
type User = crate::UserTy;
|
|
|
|
|
|
|
|
|
|
async fn handle_async(&self, params: ParameterTable<()>, _user: &Self::User) -> OperationResponse<()> {
|
|
|
|
|
polariton_server::operations::result_to_op_resp::<CODE, ()>(self.do_handling(params).await)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl polariton_server::operations::OperationCode for GarageUpgradesProvider {
|
|
|
|
|
fn op_code() -> u8 {
|
|
|
|
|
CODE
|
|
|
|
|
}
|
2025-02-23 16:10:21 -05:00
|
|
|
}
|