Skip to main content

FileAuditLogStore

Struct FileAuditLogStore 

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

File-based audit log persistent storage (JSONL format: one JSON per line)

Applicable scenarios: single-machine deployment, lightweight audit archiving, development debugging. For high-concurrency production scenarios, it is recommended to combine AsyncAuditWriter + FileAuditLogStore so that a background thread performs serial writes and avoids lock contention.

Implementations§

Source§

impl FileAuditLogStore

Source

pub fn new(path: impl Into<String>) -> Self

Create a file audit log store; the target file is created on the first append if it does not exist

Source

pub fn path(&self) -> &str

Return the storage file path

Trait Implementations§

Source§

impl AuditLogStore for FileAuditLogStore

Source§

fn append(&self, entry: &SqlAuditContext) -> Result<(), String>

Append an audit log entry (JSONL format; automatically masked before write)

Source§

fn read_all(&self) -> Result<Vec<SqlAuditContext>, String>

Read all persisted audit logs (parse JSONL line by line)

Returns an empty vec when the file does not exist (treated as no logs persisted yet).

Source§

fn clear(&self) -> Result<(), String>

Clear the persistent file (deletes the file; the next append recreates it)

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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, 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.