waveless_commons/auth/role.rs
1// Waveless
2// Copyright (C) 2026 Oscar Alvarez Gonzalez
3
4use crate::*;
5
6use super::*;
7
8/// Trait implemented for every role's storage backend.
9#[typetag::serde]
10#[async_trait]
11pub trait AnyRoleMethod: AnyExt + DatabaseConsumer {
12 /// Get the role of the given user.
13 async fn get(&self, db_conns: DbConns, user_id: UserId) -> Result<Option<CompactString>>;
14
15 /// Set the role of the given user.
16 async fn set(&self, db_conns: DbConns, user_id: UserId, role: CompactString) -> Result<()>;
17
18 /// Remove the role of the given user.
19 async fn remove(&self, db_conns: DbConns, user_id: UserId) -> Result<()>;
20}