pub trait AuthExt {
// Required methods
fn register_policy(
&self,
policy: &Policy,
) -> impl Future<Output = Result<()>> + Send;
fn get_policy(
&self,
role: &str,
) -> impl Future<Output = Result<Option<Policy>>> + Send;
fn list_policies(&self) -> impl Future<Output = Result<Vec<Policy>>> + Send;
fn assign_role(
&self,
node_id: &str,
role: &str,
) -> impl Future<Output = Result<()>> + Send;
fn get_role(
&self,
node_id: &str,
) -> impl Future<Output = Result<Option<String>>> + Send;
fn check_permission(
&self,
node_id: &str,
permission: Permission,
topic: &str,
) -> impl Future<Output = Result<bool>> + Send;
fn delete_policy(
&self,
role: &str,
) -> impl Future<Output = Result<()>> + Send;
fn unassign_role(
&self,
node_id: &str,
) -> impl Future<Output = Result<()>> + Send;
}Required Methods§
Sourcefn register_policy(
&self,
policy: &Policy,
) -> impl Future<Output = Result<()>> + Send
fn register_policy( &self, policy: &Policy, ) -> impl Future<Output = Result<()>> + Send
Register a policy
§Arguments
policy- Policy to register
§Example
use mecha10_core::prelude::*;
use mecha10_core::auth::{AuthExt, Policy, Permission};
let policy = Policy::new("camera_driver")
.allow_publish("/sensors/camera/*")
.allow_subscribe("/control/camera/*");
ctx.register_policy(&policy).await?;Sourcefn list_policies(&self) -> impl Future<Output = Result<Vec<Policy>>> + Send
fn list_policies(&self) -> impl Future<Output = Result<Vec<Policy>>> + Send
List all registered policies
Sourcefn assign_role(
&self,
node_id: &str,
role: &str,
) -> impl Future<Output = Result<()>> + Send
fn assign_role( &self, node_id: &str, role: &str, ) -> impl Future<Output = Result<()>> + Send
Sourcefn check_permission(
&self,
node_id: &str,
permission: Permission,
topic: &str,
) -> impl Future<Output = Result<bool>> + Send
fn check_permission( &self, node_id: &str, permission: Permission, topic: &str, ) -> impl Future<Output = Result<bool>> + Send
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".