pub struct Hub { /* private fields */ }Expand description
Every combat this instance has in memory, and what they need: the store, the other services and the limits.
Implementations§
Source§impl Hub
impl Hub
Sourcepub async fn start(
store: Store,
listener: PgListener,
sheet_sync: Option<SheetSync>,
monsters: Option<Monsters>,
limits: Limits,
) -> Result<Arc<Self>, Error>
pub async fn start( store: Store, listener: PgListener, sheet_sync: Option<SheetSync>, monsters: Option<Monsters>, limits: Limits, ) -> Result<Arc<Self>, Error>
Starts listening on listener for events from all instances, and the background
upkeep: evicting idle combats and retrying HP write-back. Monsters
are added from monsters.
Sourcepub async fn create(
&self,
campaign: &str,
name: &str,
quotas: &Quotas,
) -> Result<CombatSnapshot, ApiError>
pub async fn create( &self, campaign: &str, name: &str, quotas: &Quotas, ) -> Result<CombatSnapshot, ApiError>
Starts an empty combat in campaign, within its quotas.
Sourcepub async fn create_from_plan(
&self,
campaign: Uuid,
encounter: Uuid,
name: Option<&str>,
quotas: &Quotas,
) -> Result<CombatSnapshot, ApiError>
pub async fn create_from_plan( &self, campaign: Uuid, encounter: Uuid, name: Option<&str>, quotas: &Quotas, ) -> Result<CombatSnapshot, ApiError>
Creates a combat from one of campaign’s plans, with the plan’s
monsters in it, and called name or after the plan. All or nothing:
if any of the monsters can’t be added, there’s no combat.
Sourcepub async fn combat(&self, id: Uuid) -> Result<Arc<LiveCombat>, ApiError>
pub async fn combat(&self, id: Uuid) -> Result<Arc<LiveCombat>, ApiError>
The live combat, loading it from its log if it isn’t in memory.
Sourcepub async fn combat_in(
&self,
id: Uuid,
campaign: Uuid,
) -> Result<Arc<LiveCombat>, ApiError>
pub async fn combat_in( &self, id: Uuid, campaign: Uuid, ) -> Result<Arc<LiveCombat>, ApiError>
The combat, if it belongs to campaign. Another campaign’s combat
is reported as not found, so its existence isn’t revealed.
Sourcepub async fn execute(
&self,
id: Uuid,
envelope: CommandEnvelope,
claims: &Claims,
) -> Result<Outcome, ApiError>
pub async fn execute( &self, id: Uuid, envelope: CommandEnvelope, claims: &Claims, ) -> Result<Outcome, ApiError>
Runs a command sent by the device claims are for. A player’s
device may only change its own combatants (see player_may).
What the command costs a character’s sheet is spent first (no slot
left, no cast), and given back if the command is then refused.
Auto Trait Implementations§
impl !Freeze for Hub
impl !RefUnwindSafe for Hub
impl Send for Hub
impl Sync for Hub
impl Unpin for Hub
impl UnsafeUnpin for Hub
impl !UnwindSafe for Hub
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read more§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read more