pub struct AuditEvent {
pub event_type: AuditEventType,
pub timestamp: DateTime<Utc>,
pub user_id: Option<String>,
pub ip_address: Option<String>,
pub user_agent: Option<String>,
pub session_id: Option<String>,
pub request_id: Option<String>,
pub success: bool,
pub failure_reason: Option<String>,
pub metadata: HashMap<String, String>,
}Expand description
Audit event with context
Fields§
§event_type: AuditEventTypeEvent type
timestamp: DateTime<Utc>Event timestamp
user_id: Option<String>User ID (if applicable)
ip_address: Option<String>IP address
user_agent: Option<String>User agent
session_id: Option<String>Session ID (if applicable)
request_id: Option<String>Request ID for tracing
success: boolSuccess indicator
failure_reason: Option<String>Failure reason (if failed)
metadata: HashMap<String, String>Additional metadata
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 with_user_agent(self, ua: impl Into<String>) -> Self
pub fn with_user_agent(self, ua: impl Into<String>) -> Self
Set user agent
Sourcepub fn with_session(self, session_id: impl Into<String>) -> Self
pub fn with_session(self, session_id: impl Into<String>) -> Self
Set session ID
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 login_success(user_id: impl Into<String>) -> Self
pub fn login_success(user_id: impl Into<String>) -> Self
Create a login success event
Sourcepub fn login_failure(
username: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn login_failure( username: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a login failure event
Sourcepub fn token_issued(
user_id: impl Into<String>,
token_type: impl Into<String>,
) -> Self
pub fn token_issued( user_id: impl Into<String>, token_type: impl Into<String>, ) -> Self
Create a token issued event
Sourcepub fn password_changed(user_id: impl Into<String>) -> Self
pub fn password_changed(user_id: impl Into<String>) -> Self
Create a password changed event
Sourcepub fn mfa_verification(user_id: impl Into<String>, success: bool) -> Self
pub fn mfa_verification(user_id: impl Into<String>, success: bool) -> Self
Create an MFA verification event
Sourcepub fn rate_limit_exceeded(ip: impl Into<String>) -> Self
pub fn rate_limit_exceeded(ip: impl Into<String>) -> Self
Create a rate limit exceeded event
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