feat: wire bark battle platform loop
Some checks are pending
CI / verify (pull_request) Waiting to run
Some checks are pending
CI / verify (pull_request) Waiting to run
This commit is contained in:
@@ -720,6 +720,42 @@ pub(crate) fn map_asset_history_list_result(
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub type BarkBattleDraftConfigRecord = serde_json::Value;
|
||||
pub type BarkBattleRuntimeConfigRecord = serde_json::Value;
|
||||
pub type BarkBattleRunRecord = serde_json::Value;
|
||||
|
||||
pub(crate) fn map_bark_battle_draft_config_procedure_result(
|
||||
result: BarkBattleProcedureResult,
|
||||
) -> Result<BarkBattleDraftConfigRecord, SpacetimeClientError> {
|
||||
parse_bark_battle_row_json(result, "Bark Battle draft config")
|
||||
}
|
||||
|
||||
pub(crate) fn map_bark_battle_runtime_config_procedure_result(
|
||||
result: BarkBattleProcedureResult,
|
||||
) -> Result<BarkBattleRuntimeConfigRecord, SpacetimeClientError> {
|
||||
parse_bark_battle_row_json(result, "Bark Battle runtime config")
|
||||
}
|
||||
|
||||
pub(crate) fn map_bark_battle_run_procedure_result(
|
||||
result: BarkBattleProcedureResult,
|
||||
) -> Result<BarkBattleRunRecord, SpacetimeClientError> {
|
||||
parse_bark_battle_row_json(result, "Bark Battle run")
|
||||
}
|
||||
|
||||
fn parse_bark_battle_row_json<T: serde::de::DeserializeOwned>(
|
||||
result: BarkBattleProcedureResult,
|
||||
label: &'static str,
|
||||
) -> Result<T, SpacetimeClientError> {
|
||||
if !result.ok {
|
||||
return Err(SpacetimeClientError::procedure_failed(result.error_message));
|
||||
}
|
||||
let row_json = result
|
||||
.row_json
|
||||
.ok_or_else(|| SpacetimeClientError::missing_snapshot(label))?;
|
||||
serde_json::from_str(&row_json)
|
||||
.map_err(|error| SpacetimeClientError::Runtime(format!("{label} JSON 解析失败: {error}")))
|
||||
}
|
||||
|
||||
pub type CreationEntryConfigRecord =
|
||||
shared_contracts::creation_entry_config::CreationEntryConfigResponse;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user