pub struct Database {
db: Database,
}
Expand description
The database
Fields§
§db: Database
Implementations§
source§impl Database
impl Database
sourcepub async fn store_get<P, K, V>(&self, prefix: P, key: K) -> Result<Option<V>>where
P: AsRef<[u8]>,
K: AsRef<[u8]>,
V: DeserializeOwned,
pub async fn store_get<P, K, V>(&self, prefix: P, key: K) -> Result<Option<V>>where P: AsRef<[u8]>, K: AsRef<[u8]>, V: DeserializeOwned,
Get a key from the store
sourcepub async fn store_put<P, K, V>(
&self,
prefix: P,
key: K,
value: V
) -> Result<()>where
P: AsRef<[u8]>,
K: AsRef<[u8]>,
V: Serialize,
pub async fn store_put<P, K, V>( &self, prefix: P, key: K, value: V ) -> Result<()>where P: AsRef<[u8]>, K: AsRef<[u8]>, V: Serialize,
Put a key in the store
sourcepub async fn store_update<P, K, V, U>(
&self,
prefix: P,
key: K,
update_func: U
) -> Result<()>where
P: AsRef<[u8]>,
K: AsRef<[u8]>,
V: Serialize + DeserializeOwned,
U: FnOnce(Option<V>) -> V + Send + 'static,
pub async fn store_update<P, K, V, U>( &self, prefix: P, key: K, update_func: U ) -> Result<()>where P: AsRef<[u8]>, K: AsRef<[u8]>, V: Serialize + DeserializeOwned, U: FnOnce(Option<V>) -> V + Send + 'static,
Get and Put a key in the store in one action, ensuring the key is not changed between the commands.
source§impl Database
impl Database
sourcepub async fn create_tic_tac_toe_game(
&self,
guild_id: MaybeGuildString,
author: TicTacToePlayer,
author_team: Team,
opponent: TicTacToePlayer
) -> Result<TicTacToeGame, TicTacToeCreateGameError>
pub async fn create_tic_tac_toe_game( &self, guild_id: MaybeGuildString, author: TicTacToePlayer, author_team: Team, opponent: TicTacToePlayer ) -> Result<TicTacToeGame, TicTacToeCreateGameError>
Create a new tic-tac-toe game
sourcepub async fn try_tic_tac_toe_move(
&self,
guild_id: MaybeGuildString,
player: TicTacToePlayer,
move_index: u8
) -> Result<TicTacToeTryMoveResponse, TicTacToeTryMoveError>
pub async fn try_tic_tac_toe_move( &self, guild_id: MaybeGuildString, player: TicTacToePlayer, move_index: u8 ) -> Result<TicTacToeTryMoveResponse, TicTacToeTryMoveError>
Try to make a tic-tac-toe move
sourcepub async fn get_tic_tac_toe_game(
&self,
guild_id: MaybeGuildString,
player: TicTacToePlayer
) -> Result<Option<TicTacToeGame>>
pub async fn get_tic_tac_toe_game( &self, guild_id: MaybeGuildString, player: TicTacToePlayer ) -> Result<Option<TicTacToeGame>>
Try to get a tic-tac-toe game by guild and player
sourcepub async fn concede_tic_tac_toe_game(
&self,
guild_id: MaybeGuildString,
player: UserId
) -> Result<Option<TicTacToeGame>>
pub async fn concede_tic_tac_toe_game( &self, guild_id: MaybeGuildString, player: UserId ) -> Result<Option<TicTacToeGame>>
sourcepub async fn get_tic_tac_toe_score(
&self,
guild_id: MaybeGuildString,
player: UserId
) -> Result<TicTacToeScore>
pub async fn get_tic_tac_toe_score( &self, guild_id: MaybeGuildString, player: UserId ) -> Result<TicTacToeScore>
Get the user’s Tic-Tac-Toe scores
sourcepub async fn get_top_tic_tac_toe_scores(
&self,
guild_id: MaybeGuildString
) -> Result<Vec<TicTacToeTopPlayerScore>>
pub async fn get_top_tic_tac_toe_scores( &self, guild_id: MaybeGuildString ) -> Result<Vec<TicTacToeTopPlayerScore>>
Get the top Tic-Tac-Toe scores for the current server
source§impl Database
impl Database
sourcepub async fn set_tiktok_embed_flags(
&self,
guild_id: GuildId,
set_flags: TikTokEmbedFlags,
unset_flags: TikTokEmbedFlags
) -> Result<(TikTokEmbedFlags, TikTokEmbedFlags)>
pub async fn set_tiktok_embed_flags( &self, guild_id: GuildId, set_flags: TikTokEmbedFlags, unset_flags: TikTokEmbedFlags ) -> Result<(TikTokEmbedFlags, TikTokEmbedFlags)>
Set the flags for tiktok embeds.
Returns
Returns the old flags and new flags in a tuple in that order.
sourcepub async fn get_tiktok_embed_flags(
&self,
guild_id: GuildId
) -> Result<TikTokEmbedFlags>
pub async fn get_tiktok_embed_flags( &self, guild_id: GuildId ) -> Result<TikTokEmbedFlags>
Get the tiktok embed flags.
source§impl Database
impl Database
sourcepub async unsafe fn new<P>(path: P, create_if_missing: bool) -> Result<Self>where
P: Into<Utf8PathBuf>,
pub async unsafe fn new<P>(path: P, create_if_missing: bool) -> Result<Self>where P: Into<Utf8PathBuf>,
Safety
This must be called before any other sqlite functions are called.
sourcepub unsafe fn blocking_new<P>(path: P, create_if_missing: bool) -> Result<Self>where
P: AsRef<Utf8Path>,
pub unsafe fn blocking_new<P>(path: P, create_if_missing: bool) -> Result<Self>where P: AsRef<Utf8Path>,
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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
Mutably borrows from an owned value. Read more
§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
§impl<T> CloneableStorage for Twhere
T: Any + Send + Sync + Clone,
impl<T> CloneableStorage for Twhere T: Any + Send + Sync + Clone,
fn clone_storage(&self) -> Box<dyn CloneableStorage>
§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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request