pub struct CharacterStore { /* private fields */ }Expand description
Persistence for characters, in Postgres. Every operation is scoped to one campaign: a character of another campaign is simply not found.
Implementations§
Source§impl CharacterStore
impl CharacterStore
Sourcepub async fn list(&self, scope: Scope) -> Result<Vec<Character>, ApiError>
pub async fn list(&self, scope: Scope) -> Result<Vec<Character>, ApiError>
The campaign’s characters.
Sourcepub async fn count(&self, campaign: Uuid) -> Result<i64, ApiError>
pub async fn count(&self, campaign: Uuid) -> Result<i64, ApiError>
How many characters campaign keeps.
Sourcepub async fn get(&self, scope: Scope, id: Uuid) -> Result<Character, ApiError>
pub async fn get(&self, scope: Scope, id: Uuid) -> Result<Character, ApiError>
One of the campaign’s characters.
Sourcepub async fn create(
&self,
scope: Scope,
sheet: CharacterSheet,
) -> Result<Character, ApiError>
pub async fn create( &self, scope: Scope, sheet: CharacterSheet, ) -> Result<Character, ApiError>
Creates a character, played by the device creating it if that’s a player’s.
Sourcepub async fn replace(
&self,
scope: Scope,
id: Uuid,
expected_version: Option<u64>,
sheet: CharacterSheet,
) -> Result<Character, ApiError>
pub async fn replace( &self, scope: Scope, id: Uuid, expected_version: Option<u64>, sheet: CharacterSheet, ) -> Result<Character, ApiError>
Replaces the sheet if the stored version still equals
expected_version (None skips the check). The compare and the write
happen in one statement, so there’s no window for another write.
Sourcepub async fn apply(
&self,
scope: Scope,
id: Uuid,
action: &CharacterAction,
key: Option<&str>,
) -> Result<Character, ApiError>
pub async fn apply( &self, scope: Scope, id: Uuid, action: &CharacterAction, key: Option<&str>, ) -> Result<Character, ApiError>
Applies action to the sheet, atomically: the character’s row stays
locked until it’s written, so concurrent actions (two clients
spending the same slot) take turns. With a key, only once: sent
again with the same key, the character is returned as it now is.
Sourcepub async fn set_owners(
&self,
scope: Scope,
id: Uuid,
owners: &[String],
) -> Result<Character, ApiError>
pub async fn set_owners( &self, scope: Scope, id: Uuid, owners: &[String], ) -> Result<Character, ApiError>
Sets which player devices play the character, by key. That’s a change like any other: the version moves on.
Sourcepub async fn delete_campaign(&self, campaign: Uuid) -> Result<u64, ApiError>
pub async fn delete_campaign(&self, campaign: Uuid) -> Result<u64, ApiError>
Deletes every character of a campaign; returns how many there were. (Their applied actions go with them.)
Sourcepub async fn export_campaign(
&self,
campaign: Uuid,
) -> Result<Vec<Character>, ApiError>
pub async fn export_campaign( &self, campaign: Uuid, ) -> Result<Vec<Character>, ApiError>
Every character of campaign, as they are, to keep or move
elsewhere.
Trait Implementations§
Source§impl Clone for CharacterStore
impl Clone for CharacterStore
Source§fn clone(&self) -> CharacterStore
fn clone(&self) -> CharacterStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CharacterStore
impl !RefUnwindSafe for CharacterStore
impl Send for CharacterStore
impl Sync for CharacterStore
impl Unpin for CharacterStore
impl UnsafeUnpin for CharacterStore
impl !UnwindSafe for CharacterStore
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