Skip to main content

AuditRegistry

Struct AuditRegistry 

Source
pub struct AuditRegistry { /* private fields */ }
Expand description

Registry for managing audit targets

Implementations§

Source§

impl AuditRegistry

Source

pub fn new() -> Self

Creates a new AuditRegistry

Source

pub fn supports_target_type(&self, target_type: &str) -> bool

Source

pub async fn create_target( &self, target_type: &str, id: String, config: &KVS, ) -> Result<Box<dyn Target<AuditEntry> + Send + Sync>, TargetError>

Creates a target of the specified type with the given ID and configuration

§Arguments
  • target_type - The type of the target (e.g., “webhook”, “mqtt”).
  • id - The identifier for the target instance.
  • config - The configuration key-value store for the target.
§Returns
  • Result<Box<dyn Target<AuditEntry> + Send + Sync>, TargetError> - The created target or an error.
Source

pub async fn create_audit_targets_from_config( &self, config: &Config, ) -> AuditResult<Vec<Box<dyn Target<AuditEntry> + Send + Sync>>>

Creates all targets from a configuration Create all notification targets from system configuration and environment variables. This method processes the creation of each target concurrently as follows:

  1. Iterate through all registered target types (e.g. webhooks, mqtt).
  2. For each type, resolve its configuration in the configuration file and environment variables.
  3. Identify all target instance IDs that need to be created.
  4. Combine the default configuration, file configuration, and environment variable configuration for each instance.
  5. If the instance is enabled, create an asynchronous task for it to instantiate.
  6. Concurrency executes all creation tasks and collects results.
Source

pub fn add_target( &mut self, _id: String, target: Box<dyn Target<AuditEntry> + Send + Sync>, )

Adds a target to the registry

§Arguments
  • id - The identifier for the target.
  • target - The target instance to be added.
Source

pub fn add_shared_target( &mut self, _id: String, target: SharedTarget<AuditEntry>, )

Source

pub async fn remove_target( &mut self, id: &str, ) -> Option<SharedTarget<AuditEntry>>

Removes a target from the registry

§Arguments
  • id - The identifier for the target to be removed.
§Returns
  • Option<SharedTarget<AuditEntry>> - The removed target if it existed.
Source

pub fn get_target(&self, id: &str) -> Option<SharedTarget<AuditEntry>>

Gets a target from the registry

§Arguments
  • id - The identifier for the target to be retrieved.
§Returns
  • Option<SharedTarget<AuditEntry>> - The target if it exists.
Source

pub fn list_target_values(&self) -> Vec<SharedTarget<AuditEntry>>

Lists cloned target values for runtime inspection without exposing mutable registry access.

Source

pub fn runtime_manager(&self) -> &TargetRuntimeManager<AuditEntry>

Source

pub fn runtime_manager_mut(&mut self) -> &mut TargetRuntimeManager<AuditEntry>

Source

pub fn list_targets(&self) -> Vec<String>

Lists all target IDs

§Returns
  • Vec<String> - A vector of all target IDs in the registry.
Source

pub async fn close_all(&mut self) -> AuditResult<()>

Closes all targets and clears the registry

§Returns
  • AuditResult<()> - Result indicating success or failure.
Source

pub fn create_key(&self, target_type: &str, target_id: &str) -> String

Creates a unique key for a target based on its type and ID

§Arguments
  • target_type - The type of the target (e.g., “webhook”, “mqtt”).
  • target_id - The identifier for the target instance.
§Returns
  • String - The unique key for the target.
Source

pub fn enable_target( &self, target_type: &str, target_id: &str, ) -> AuditResult<()>

Enables a target (placeholder, assumes target exists)

§Arguments
  • target_type - The type of the target (e.g., “webhook”, “mqtt”).
  • target_id - The identifier for the target instance.
§Returns
  • AuditResult<()> - Result indicating success or failure.
Source

pub fn disable_target( &self, target_type: &str, target_id: &str, ) -> AuditResult<()>

Disables a target (placeholder, assumes target exists)

§Arguments
  • target_type - The type of the target (e.g., “webhook”, “mqtt”).
  • target_id - The identifier for the target instance.
§Returns
  • AuditResult<()> - Result indicating success or failure.
Source

pub fn upsert_target( &mut self, target_type: &str, target_id: &str, target: Box<dyn Target<AuditEntry> + Send + Sync>, ) -> AuditResult<()>

Upserts a target into the registry

§Arguments
  • target_type - The type of the target (e.g., “webhook”, “mqtt”).
  • target_id - The identifier for the target instance.
  • target - The target instance to be upserted.
§Returns
  • AuditResult<()> - Result indicating success or failure.

Trait Implementations§

Source§

impl Default for AuditRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromExt for T

Source§

fn from_<T>(t: T) -> Self
where Self: From<T>,

Source§

impl<T> Instrument for T

Source§

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

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

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> IntoExt for T

Source§

fn into_<T>(self) -> T
where Self: Into<T>,

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T> TryFromExt for T

Source§

fn try_from_<T>(t: T) -> Result<Self, Self::Error>
where Self: TryFrom<T>,

Source§

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

Source§

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.
Source§

impl<T> TryIntoExt for T

Source§

fn try_into_<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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