139 lines
5.2 KiB
Rust
139 lines
5.2 KiB
Rust
use super::*;
|
|
|
|
pub type BarkBattleDraftCreateRecordInput = BarkBattleDraftCreateInput;
|
|
pub type BarkBattleDraftConfigUpsertRecordInput = BarkBattleDraftConfigUpsertInput;
|
|
pub type BarkBattleWorkPublishRecordInput = BarkBattleWorkPublishInput;
|
|
pub type BarkBattleRunStartRecordInput = BarkBattleRunStartInput;
|
|
pub type BarkBattleRunFinishRecordInput = BarkBattleRunFinishInput;
|
|
|
|
impl SpacetimeClient {
|
|
pub async fn create_bark_battle_draft(
|
|
&self,
|
|
input: BarkBattleDraftCreateRecordInput,
|
|
) -> Result<BarkBattleDraftConfigRecord, SpacetimeClientError> {
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.create_bark_battle_draft_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_draft_config_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn update_bark_battle_draft_config(
|
|
&self,
|
|
input: BarkBattleDraftConfigUpsertRecordInput,
|
|
) -> Result<BarkBattleDraftConfigRecord, SpacetimeClientError> {
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.update_bark_battle_draft_config_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_draft_config_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn publish_bark_battle_work(
|
|
&self,
|
|
input: BarkBattleWorkPublishRecordInput,
|
|
) -> Result<BarkBattleRuntimeConfigRecord, SpacetimeClientError> {
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.publish_bark_battle_work_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_runtime_config_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_bark_battle_runtime_config(
|
|
&self,
|
|
work_id: String,
|
|
owner_user_id: Option<String>,
|
|
) -> Result<BarkBattleRuntimeConfigRecord, SpacetimeClientError> {
|
|
let input = BarkBattleRuntimeConfigGetInput {
|
|
work_id,
|
|
owner_user_id,
|
|
};
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_bark_battle_runtime_config_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_runtime_config_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn start_bark_battle_run(
|
|
&self,
|
|
input: BarkBattleRunStartRecordInput,
|
|
) -> Result<BarkBattleRunRecord, SpacetimeClientError> {
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.start_bark_battle_run_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_run_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn finish_bark_battle_run(
|
|
&self,
|
|
input: BarkBattleRunFinishRecordInput,
|
|
) -> Result<BarkBattleRunRecord, SpacetimeClientError> {
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.finish_bark_battle_run_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_run_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
|
|
pub async fn get_bark_battle_run(
|
|
&self,
|
|
run_id: String,
|
|
owner_user_id: String,
|
|
) -> Result<BarkBattleRunRecord, SpacetimeClientError> {
|
|
let input = BarkBattleRunGetInput {
|
|
run_id,
|
|
owner_user_id,
|
|
};
|
|
self.call_after_connect(move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_bark_battle_run_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(|error| SpacetimeClientError::Procedure(error.to_string()))
|
|
.and_then(map_bark_battle_run_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
})
|
|
.await
|
|
}
|
|
}
|