pub struct Store { /* private fields */ }Expand description
Combats, their logs and planned encounters, in Postgres.
Implementations§
Source§impl Store
impl Store
Sourcepub async fn export_campaign(
&self,
campaign: Uuid,
) -> Result<CombatExport, ApiError>
pub async fn export_campaign( &self, campaign: Uuid, ) -> Result<CombatExport, ApiError>
The campaign’s combats and plans, as they are.
Sourcepub async fn import_campaign(
&self,
campaign: Uuid,
export: &CombatExport,
) -> Result<u64, ApiError>
pub async fn import_campaign( &self, campaign: Uuid, export: &CombatExport, ) -> Result<u64, ApiError>
Takes in a campaign’s combats and plans exported elsewhere, as they were; returns how many came. All or nothing, and only while it has none here. Each combat’s log must be whole, from its creation in this campaign on; the rest follows from it.
Source§impl Store
impl Store
Sourcepub async fn create(
&self,
campaign: &str,
name: &str,
setup: Vec<CombatEvent>,
) -> Result<Uuid, ApiError>
pub async fn create( &self, campaign: &str, name: &str, setup: Vec<CombatEvent>, ) -> Result<Uuid, ApiError>
Creates a combat whose log starts with a Created event, followed
by setup (a plan’s monsters, say), all at once.
Sourcepub async fn count(&self, campaign: &str) -> Result<i64, ApiError>
pub async fn count(&self, campaign: &str) -> Result<i64, ApiError>
How many combats campaign keeps.
Sourcepub async fn list(
&self,
filter: &ListFilter,
) -> Result<Vec<CombatSummary>, ApiError>
pub async fn list( &self, filter: &ListFilter, ) -> Result<Vec<CombatSummary>, ApiError>
Most recently active first.
Sourcepub async fn events(
&self,
id: Uuid,
after: u64,
) -> Result<Option<Vec<LoggedEvent>>, ApiError>
pub async fn events( &self, id: Uuid, after: u64, ) -> Result<Option<Vec<LoggedEvent>>, ApiError>
The combat’s log from after + 1 onwards, or None if there’s no
such combat.
Sourcepub async fn delete_campaign(&self, campaign: &str) -> Result<u64, ApiError>
pub async fn delete_campaign(&self, campaign: &str) -> Result<u64, ApiError>
Deletes every combat of a campaign, logs and all; returns how many there were. (Its planned encounters go too.)
Sourcepub async fn events_for_command(
&self,
id: Uuid,
command_id: Uuid,
) -> Result<Vec<LoggedEvent>, ApiError>
pub async fn events_for_command( &self, id: Uuid, command_id: Uuid, ) -> Result<Vec<LoggedEvent>, ApiError>
The events a given command produced.
Sourcepub async fn lock(&self, tx: &mut Tx, id: Uuid) -> Result<Option<u64>, ApiError>
pub async fn lock(&self, tx: &mut Tx, id: Uuid) -> Result<Option<u64>, ApiError>
Locks the combat until tx ends, so no other command (on any
instance) can append in the meantime. Returns the latest seq, or
None if there’s no such combat.
Sourcepub async fn events_in(
&self,
tx: &mut Tx,
id: Uuid,
after: u64,
) -> Result<Vec<LoggedEvent>, ApiError>
pub async fn events_in( &self, tx: &mut Tx, id: Uuid, after: u64, ) -> Result<Vec<LoggedEvent>, ApiError>
A combat’s events after after, inside tx.
Sourcepub async fn record_command(
&self,
tx: &mut Tx,
id: Uuid,
command_id: Uuid,
actor_key: &str,
) -> Result<bool, ApiError>
pub async fn record_command( &self, tx: &mut Tx, id: Uuid, command_id: Uuid, actor_key: &str, ) -> Result<bool, ApiError>
Records that a command sent by the device with actor_key is being
applied. false if it already was.
Sourcepub async fn commands_by(
&self,
tx: &mut Tx,
id: Uuid,
actor_key: &str,
) -> Result<HashSet<Uuid>, ApiError>
pub async fn commands_by( &self, tx: &mut Tx, id: Uuid, actor_key: &str, ) -> Result<HashSet<Uuid>, ApiError>
The commands to this combat sent by the device with actor_key.
Sourcepub async fn append(
&self,
tx: &mut Tx,
id: Uuid,
events: &[LoggedEvent],
state: &CombatState,
) -> Result<(), ApiError>
pub async fn append( &self, tx: &mut Tx, id: Uuid, events: &[LoggedEvent], state: &CombatState, ) -> Result<(), ApiError>
Appends events (non-empty, continuing the log), refreshes the
summary and announces them on CHANNEL once tx commits.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl !RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl !UnwindSafe for Store
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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