pub struct CombatClient { /* private fields */ }Expand description
The combat service’s client: combats and planned encounters.
Implementations§
Source§impl CombatClient
impl CombatClient
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
A client for the combat service at base_url, without a token.
Sourcepub fn with_token(self, token: &str) -> Self
pub fn with_token(self, token: &str) -> Self
Sends token (from crate::auth::AuthClient::login) with every
request, and when connecting.
Sourcepub async fn list(
&self,
status: Option<CombatStatus>,
) -> Result<Vec<CombatSummary>, ClientError>
pub async fn list( &self, status: Option<CombatStatus>, ) -> Result<Vec<CombatSummary>, ClientError>
The logged-in campaign’s combats, most recently active first, optionally only those in one status (e.g. paused combats waiting to be resumed).
Sourcepub async fn create(&self, name: &str) -> Result<CombatSnapshot, ClientError>
pub async fn create(&self, name: &str) -> Result<CombatSnapshot, ClientError>
Creates a combat in the logged-in campaign.
Sourcepub async fn create_from_plan(
&self,
encounter: Uuid,
name: Option<&str>,
) -> Result<CombatSnapshot, ClientError>
pub async fn create_from_plan( &self, encounter: Uuid, name: Option<&str>, ) -> Result<CombatSnapshot, ClientError>
Creates a combat from a planned encounter, with the plan’s monsters
in it, called name or after the plan. All or nothing.
Sourcepub async fn snapshot(&self, id: Uuid) -> Result<CombatSnapshot, ClientError>
pub async fn snapshot(&self, id: Uuid) -> Result<CombatSnapshot, ClientError>
Round, whose turn it is, initiative order and effects in play.
Sourcepub async fn log(
&self,
id: Uuid,
after: u64,
) -> Result<Vec<LoggedEvent>, ClientError>
pub async fn log( &self, id: Uuid, after: u64, ) -> Result<Vec<LoggedEvent>, ClientError>
The log after position after (0 for all of it).
Sourcepub async fn command(
&self,
id: Uuid,
envelope: &CommandEnvelope,
) -> Result<Vec<LoggedEvent>, ClientError>
pub async fn command( &self, id: Uuid, envelope: &CommandEnvelope, ) -> Result<Vec<LoggedEvent>, ClientError>
Runs a command over plain HTTP and returns the events it produced.
Safe to retry: a repeated command_id returns the original events.
Sourcepub async fn encounters(&self) -> Result<Vec<Encounter>, ClientError>
pub async fn encounters(&self) -> Result<Vec<Encounter>, ClientError>
The campaign’s planned encounters, by name.
Sourcepub async fn encounter(&self, id: Uuid) -> Result<Encounter, ClientError>
pub async fn encounter(&self, id: Uuid) -> Result<Encounter, ClientError>
One planned encounter.
Sourcepub async fn create_encounter(
&self,
plan: &EncounterPlan,
) -> Result<Encounter, ClientError>
pub async fn create_encounter( &self, plan: &EncounterPlan, ) -> Result<Encounter, ClientError>
Keeps a new plan.
Sourcepub async fn replace_encounter(
&self,
id: Uuid,
plan: &EncounterPlan,
) -> Result<Encounter, ClientError>
pub async fn replace_encounter( &self, id: Uuid, plan: &EncounterPlan, ) -> Result<Encounter, ClientError>
Replaces a plan; the last save wins.
Sourcepub async fn delete_encounter(&self, id: Uuid) -> Result<(), ClientError>
pub async fn delete_encounter(&self, id: Uuid) -> Result<(), ClientError>
Deletes a plan.
Sourcepub async fn connect(&self, id: Uuid) -> Result<CombatConnection, ClientError>
pub async fn connect(&self, id: Uuid) -> Result<CombatConnection, ClientError>
Opens a live connection. The first message is always a snapshot.
Trait Implementations§
Source§impl Clone for CombatClient
impl Clone for CombatClient
Source§fn clone(&self) -> CombatClient
fn clone(&self) -> CombatClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more