Skip to main content

Client

Struct Client 

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

A single Redis endpoint housing an audit log.

Implementations§

Source§

impl Client

Source

pub fn connect(url: &str) -> AudisResult<Client>

Connect to a Redis instance, by URL.

This implementation understands the same URL formats that the underlying redis crate understands. Primarily, this means the following should work:

  • redis://127.0.0.1:6379
  • redis://localhost
  • unix:/path/to/redis.sock
Source

pub fn background( &self, n: usize, ) -> AudisResult<(SyncSender<Event>, JoinHandle<()>)>

Delegate event logging to a background thread.

This function spins up a new thread, with a copy of the audis Client object, and returns a channel for sending new audis::Event objects to be logged, and the thread JoinHandle for waiting on the thread to finish.

The sending channel is buffered, and will have enough space to keep n Event objects in memory. If n is passed as zero, a suitable default will be used instead.

If the background thread encounters an error while trying to log an Event to the Redis backend, it will print out the error and attempt to recover.

To shut down the background thread, drop the returned SyncSender object and then join the thread’s JoinHandle.

Source

pub fn subjects(&self) -> AudisResult<Vec<String>>

Return the list of all known subjects.

Source

pub fn log(&self, e: &Event) -> AudisResult<&Client>

Log an event to the audit log.

Source

pub fn retrieve(&self, log: &str) -> AudisResult<Vec<Event>>

Retrieve the full list of events for the given subject.

Source

pub fn truncate(&self, log: &str, n: u32) -> AudisResult<&Client>

Truncate a subject so that it only contains n Events.

Source

pub fn purge(&self, log: &str, last: &str) -> AudisResult<&Client>

Delete the Event last and all prior events from a given subject.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.