pub struct AuditEvent {
pub id: String,
pub timestamp: i64,
pub tenant_id: Option<String>,
pub event_type: AuditEventType,
pub actor: Option<String>,
pub ip_address: Option<String>,
pub user_agent: Option<String>,
pub request_id: Option<String>,
pub metadata: HashMap<String, String>,
pub integrity_hash: Option<String>,
}Expand description
Audit event
Fields§
§id: StringUnique event ID
timestamp: i64Timestamp (Unix epoch milliseconds)
tenant_id: Option<String>Tenant ID (for multi-tenancy)
event_type: AuditEventTypeEvent type and details
actor: Option<String>Actor performing the action (user, service, etc.)
ip_address: Option<String>IP address of the request
user_agent: Option<String>User agent or service identifier
request_id: Option<String>Request ID for correlation
metadata: HashMap<String, String>Additional metadata
integrity_hash: Option<String>Integrity hash (for tamper detection)
Implementations§
Source§impl AuditEvent
impl AuditEvent
Sourcepub fn new(event_type: AuditEventType) -> Self
pub fn new(event_type: AuditEventType) -> Self
Create a new audit event
Sourcepub fn permission_check(
subject: impl Into<String>,
resource: impl Into<String>,
relation: impl Into<String>,
allowed: bool,
tenant_id: Option<String>,
) -> Self
pub fn permission_check( subject: impl Into<String>, resource: impl Into<String>, relation: impl Into<String>, allowed: bool, tenant_id: Option<String>, ) -> Self
Create a permission check event
Sourcepub fn tuple_write(tuple: &RelationTuple, tenant_id: Option<String>) -> Self
pub fn tuple_write(tuple: &RelationTuple, tenant_id: Option<String>) -> Self
Create a tuple write event
Sourcepub fn tuple_delete(tuple: &RelationTuple, tenant_id: Option<String>) -> Self
pub fn tuple_delete(tuple: &RelationTuple, tenant_id: Option<String>) -> Self
Create a tuple delete event
Sourcepub fn with_actor(self, actor: impl Into<String>) -> Self
pub fn with_actor(self, actor: impl Into<String>) -> Self
Set actor
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Set request ID
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata
Sourcepub fn compute_integrity_hash(&mut self)
pub fn compute_integrity_hash(&mut self)
Compute integrity hash for tamper detection
Sourcepub fn verify_integrity(&self) -> bool
pub fn verify_integrity(&self) -> bool
Verify integrity hash
Trait Implementations§
Source§impl Clone for AuditEvent
impl Clone for AuditEvent
Source§fn clone(&self) -> AuditEvent
fn clone(&self) -> AuditEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AuditEvent
impl Debug for AuditEvent
Source§impl<'de> Deserialize<'de> for AuditEvent
impl<'de> Deserialize<'de> for AuditEvent
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
Auto Trait Implementations§
impl Freeze for AuditEvent
impl RefUnwindSafe for AuditEvent
impl Send for AuditEvent
impl Sync for AuditEvent
impl Unpin for AuditEvent
impl UnwindSafe for AuditEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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