baubot_core::prelude

Trait BauData

Source
pub trait BauData
where Self: Sync + Send,
{ // Required methods fn register_user_chat_id( &self, username: &str, ) -> impl Future<Output = Option<i64>> + Send; fn insert_chat_id( &self, username: &str, chat_id: i64, ) -> impl Future<Output = Result<Option<i64>, String>> + Send; fn delete_chat_id( &self, username: &str, ) -> impl Future<Output = Result<i64, String>> + Send; fn get_chat_id( &self, username: &str, ) -> impl Future<Output = Option<i64>> + Send; fn is_admin(&self, username: &str) -> impl Future<Output = bool> + Send; }
Expand description

Trait for database that crate::BauBot is able to interact with

Required Methods§

Source

fn register_user_chat_id( &self, username: &str, ) -> impl Future<Output = Option<i64>> + Send

Get user’s chat_id from the DB based on the suppled username. Please remember that any String output gets parsed by crate::BauBot as a Html entity.

§Safety

The implementation of this trait should make all necessary authentication choices at the appropriate stages (e.g. verifying that the user is allowed to receive or send requests)

Source

fn insert_chat_id( &self, username: &str, chat_id: i64, ) -> impl Future<Output = Result<Option<i64>, String>> + Send

Insert user’s username into the DB together with their chat_id. Please remember that any String output gets parsed by crate::BauBot as a Html entity.

§Safety

The implementation of this trait should make all necessary authentication choices at the appropriate stages (e.g. verifying that the user is allowed to receive or send requests)

Source

fn delete_chat_id( &self, username: &str, ) -> impl Future<Output = Result<i64, String>> + Send

Delete user’s username into the DB together with their chat_id. Please remember that any String output gets parsed by crate::BauBot as a Html entity.

§Safety

The implementation of this trait should make all necessary authentication choices at the appropriate stages (e.g. verifying that the user is allowed to receive or send requests)

Source

fn get_chat_id( &self, username: &str, ) -> impl Future<Output = Option<i64>> + Send

Get chat_id for username

§Safety

The implementation of this trait should make all necessary authentication choices at the appropriate stages (e.g. verifying that the user is allowed to receive or send requests)

Source

fn is_admin(&self, username: &str) -> impl Future<Output = bool> + Send

Check if username is an admin.

§Safety

The implementation of this trait should make all necessary authentication choices at the appropriate stages (e.g. verifying that the user is allowed to receive or send requests)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§