Struct bonsaidb_core::admin::Role
source · Expand description
An assignable role, which grants permissions based on the associated PermissionGroup
s.
Fields§
§name: String
The name of the role. Must be unique.
groups: Vec<u64>
The IDs of the permission groups this role belongs to.
Implementations§
source§impl Role
impl Role
sourcepub fn named<S: Into<String>>(name: S) -> Self
pub fn named<S: Into<String>>(name: S) -> Self
Returns a new role with no groups and the name provided.
sourcepub fn with_group_ids<I: IntoIterator<Item = u64>>(self, ids: I) -> Self
pub fn with_group_ids<I: IntoIterator<Item = u64>>(self, ids: I) -> Self
Builder-style method. Returns self after replacing the current groups with ids
.
pub fn assume_identity<'name, Storage: StorageConnection>(
name_or_id: impl Nameable<'name, u64>,
storage: &Storage
) -> Result<Storage::Authenticated, Error>
pub async fn assume_identity_async<'name, Storage: AsyncStorageConnection>(
name_or_id: impl Nameable<'name, u64> + Send,
storage: &Storage
) -> Result<Storage::Authenticated, Error>
sourcepub fn effective_permissions<C: Connection>(
&self,
admin: &C,
inherit_permissions: &Permissions
) -> Result<Permissions, Error>
pub fn effective_permissions<C: Connection>(
&self,
admin: &C,
inherit_permissions: &Permissions
) -> Result<Permissions, Error>
Calculates the effective permissions based on the groups this role is assigned.
Trait Implementations§
source§impl Collection for Role
impl Collection for Role
§type PrimaryKey = u64
type PrimaryKey = u64
The unique id type. Each document stored in a collection will be
uniquely identified by this type. Read more
source§fn collection_name() -> CollectionName
fn collection_name() -> CollectionName
source§impl DefaultSerialization for Role
impl DefaultSerialization for Role
source§fn natural_id(&self) -> Option<Self::PrimaryKey>
fn natural_id(&self) -> Option<Self::PrimaryKey>
Returns the natural identifier of
contents
. This is called when
pushing values into a collection, before attempting to automatically
assign a unique id. Read moresource§impl<'de> Deserialize<'de> for Role
impl<'de> Deserialize<'de> for Role
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl NamedCollection for Role
impl NamedCollection for Role
§type ByNameView = ByName
type ByNameView = ByName
The name view defined for the collection.
source§fn load<'name, N: Nameable<'name, Self::PrimaryKey> + Send + Sync, C: Connection>(
id: N,
connection: &C
) -> Result<Option<CollectionDocument<Self>>, Error>where
Self: SerializedCollection + Sized + 'static,
fn load<'name, N: Nameable<'name, Self::PrimaryKey> + Send + Sync, C: Connection>(
id: N,
connection: &C
) -> Result<Option<CollectionDocument<Self>>, Error>where
Self: SerializedCollection + Sized + 'static,
source§fn load_async<'name, 'life0, 'async_trait, N, C>(
id: N,
connection: &'life0 C
) -> Pin<Box<dyn Future<Output = Result<Option<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>where
Self: SerializedCollection + Sized + 'static + Send + 'async_trait,
N: 'async_trait + Nameable<'name, Self::PrimaryKey> + Send + Sync,
C: 'async_trait + AsyncConnection,
'name: 'async_trait,
'life0: 'async_trait,
fn load_async<'name, 'life0, 'async_trait, N, C>(
id: N,
connection: &'life0 C
) -> Pin<Box<dyn Future<Output = Result<Option<CollectionDocument<Self>>, Error>> + Send + 'async_trait>>where
Self: SerializedCollection + Sized + 'static + Send + 'async_trait,
N: 'async_trait + Nameable<'name, Self::PrimaryKey> + Send + Sync,
C: 'async_trait + AsyncConnection,
'name: 'async_trait,
'life0: 'async_trait,
source§fn entry<'connection, 'name, N: Into<NamedReference<'name, Self::PrimaryKey>> + Send + Sync, C: Connection>(
id: N,
connection: &'connection C
) -> Entry<'connection, 'name, C, Self, (), ()>where
Self: SerializedCollection + Sized,
fn entry<'connection, 'name, N: Into<NamedReference<'name, Self::PrimaryKey>> + Send + Sync, C: Connection>(
id: N,
connection: &'connection C
) -> Entry<'connection, 'name, C, Self, (), ()>where
Self: SerializedCollection + Sized,
source§fn entry_async<'connection, 'name, N: Into<NamedReference<'name, Self::PrimaryKey>> + Send + Sync, C: AsyncConnection>(
id: N,
connection: &'connection C
) -> AsyncEntry<'connection, 'name, C, Self, (), ()> ⓘwhere
Self: SerializedCollection + Sized,
fn entry_async<'connection, 'name, N: Into<NamedReference<'name, Self::PrimaryKey>> + Send + Sync, C: AsyncConnection>(
id: N,
connection: &'connection C
) -> AsyncEntry<'connection, 'name, C, Self, (), ()> ⓘwhere
Self: SerializedCollection + Sized,
source§fn load_document<'name, N: Nameable<'name, Self::PrimaryKey> + Send + Sync, C: Connection>(
name: N,
connection: &C
) -> Result<Option<OwnedDocument>, Error>where
Self: SerializedCollection + Sized,
fn load_document<'name, N: Nameable<'name, Self::PrimaryKey> + Send + Sync, C: Connection>(
name: N,
connection: &C
) -> Result<Option<OwnedDocument>, Error>where
Self: SerializedCollection + Sized,
Loads a document from this collection by name, if applicable. Return
Ok(None)
if unsupported. Read moresource§fn load_document_async<'name, 'life0, 'async_trait, N, C>(
name: N,
connection: &'life0 C
) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait>>where
Self: SerializedCollection + Sized + Send + 'async_trait,
N: 'async_trait + Nameable<'name, Self::PrimaryKey> + Send + Sync,
C: 'async_trait + AsyncConnection,
'name: 'async_trait,
'life0: 'async_trait,
fn load_document_async<'name, 'life0, 'async_trait, N, C>(
name: N,
connection: &'life0 C
) -> Pin<Box<dyn Future<Output = Result<Option<OwnedDocument>, Error>> + Send + 'async_trait>>where
Self: SerializedCollection + Sized + Send + 'async_trait,
N: 'async_trait + Nameable<'name, Self::PrimaryKey> + Send + Sync,
C: 'async_trait + AsyncConnection,
'name: 'async_trait,
'life0: 'async_trait,
Loads a document from this collection by name, if applicable. Return
Ok(None)
if unsupported. Read moresource§fn delete_by_name<C: Connection>(
name: &str,
connection: &C
) -> Result<bool, Error>where
Self: SerializedCollection + Sized,
fn delete_by_name<C: Connection>(
name: &str,
connection: &C
) -> Result<bool, Error>where
Self: SerializedCollection + Sized,
Deletes a document by its name. Returns true if a document was deleted.
source§fn delete_by_name_async<'life0, 'life1, 'async_trait, C>(
name: &'life0 str,
connection: &'life1 C
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
Self: SerializedCollection + Sized + Send + 'async_trait,
C: 'async_trait + AsyncConnection,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_by_name_async<'life0, 'life1, 'async_trait, C>(
name: &'life0 str,
connection: &'life1 C
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
Self: SerializedCollection + Sized + Send + 'async_trait,
C: 'async_trait + AsyncConnection,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes a document by its name. Returns true if a document was deleted.
Auto Trait Implementations§
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnwindSafe for Role
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Schema for Twhere
T: 'static + Collection,
impl<T> Schema for Twhere
T: 'static + Collection,
source§fn schema_name() -> SchemaName
fn schema_name() -> SchemaName
Returns the unique
SchemaName
for this schema.