Struct guppy::db::Database

source ·
pub struct Database {
    pub base: StarterDatabase,
    pub auth: AuthDatabase,
    pub logs: LogDatabase,
}

Fields§

§base: StarterDatabase§auth: AuthDatabase§logs: LogDatabase

Implementations§

source§

impl Database

source

pub async fn new(opts: DatabaseOpts) -> Database

source

pub async fn init(&self)

source

pub async fn get_user_by_hashed( &self, hashed: String ) -> DefaultReturn<Option<FullUser<String>>>

Get a user by their hashed ID

§Arguments:
  • hashed - String of the user’s hashed ID
source

pub async fn get_user_by_unhashed( &self, unhashed: String ) -> DefaultReturn<Option<FullUser<String>>>

Get a user by their unhashed ID (hashes ID and then calls Database::get_user_by_hashed())

Calls Database::get_user_by_unhashed_st() if user is invalid.

§Arguments:
  • unhashed - String of the user’s unhashed ID
source

pub async fn get_user_by_unhashed_st( &self, unhashed: String ) -> DefaultReturn<Option<FullUser<String>>>

Get a user by their unhashed secondary token

§Arguments:
  • unhashed - String of the user’s unhashed secondary token
source

pub async fn get_user_by_username( &self, username: String ) -> DefaultReturn<Option<FullUser<String>>>

Get a user by their username

§Arguments:
  • username - String of the user’s username
source

pub async fn get_level_by_role( &self, name: String ) -> DefaultReturn<RoleLevelLog>

Get a RoleLevel by its name

§Arguments:
  • name - String of the level’s role name
source

pub async fn create_user( &self, username: String ) -> DefaultReturn<Option<String>>

Create a new user given their username. Returns their hashed ID

§Arguments:
  • username - String of the user’s username
source

pub async fn edit_user_metadata_by_name( &self, name: String, metadata: UserMetadata ) -> DefaultReturn<Option<String>>

Update a UserState’s metadata by its username

source

pub async fn ban_user_by_name( &self, name: String ) -> DefaultReturn<Option<String>>

Ban a UserState by its username

source

pub async fn get_follow_by_user( &self, user: String, is_following: String ) -> DefaultReturn<Option<Log>>

Get a UserFollow by the username of the user following

§Arguments:
  • user - username of user following
  • is_following - the username of the user that user is following
source

pub async fn get_user_followers( &self, user: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<Log>>>

Get the UserFollows that are following the given user

§Arguments:
  • user - username of user to check
  • offset - optional value representing the SQL fetch offset
source

pub async fn get_user_following( &self, user: String, offset: Option<i32> ) -> DefaultReturn<Option<Vec<Log>>>

Get the UserFollows that the given user is following

§Arguments:
  • user - username of user to check
  • offset - optional value representing the SQL fetch offset
source

pub async fn get_user_follow_count(&self, user: String) -> DefaultReturn<usize>

Get the amount of followers a user has

§Arguments:
  • user - username of user to check
source

pub async fn get_user_following_count( &self, user: String ) -> DefaultReturn<usize>

Get the amount of users a user is following

§Arguments:
  • user - username of user to check
source

pub async fn toggle_user_follow( &self, props: &mut UserFollow ) -> DefaultReturn<Option<String>>

Toggle the following status of user on is_following (UserFollow)

§Arguments:

Trait Implementations§

source§

impl Clone for Database

source§

fn clone(&self) -> Database

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more