Skip to main content

Builder

Struct Builder 

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

Fills in an Entry and writes it.

Made by Trail::event or, with the request context already filled in, by req.audit(...).

Implementations§

Source§

impl Builder

Source

pub fn by(self, id: i64, name: impl Into<String>) -> Builder

Who did it. Takes the name as well, because a name read back later is the name the account has now, which is not what happened.

Source

pub fn named(self, name: impl Into<String>) -> Builder

The actor’s name, when the id is not to hand.

Separate from by because the two are not always known together: a request that is in the middle of signing somebody in has their name but no identity on the request yet, and one recording a failed attempt has neither.

Source

pub fn on(self, kind: impl Into<String>, id: impl Display) -> Builder

What was acted on: a type name and its key.

Source

pub fn describe(self, description: impl Into<String>) -> Builder

The sentence somebody will read on the audit page.

Source

pub fn from_ip(self, ip: impl Into<String>) -> Builder

Source

pub fn user_agent(self, agent: impl Into<String>) -> Builder

Source

pub fn with(self, key: &str, value: impl Into<Json>) -> Builder

One extra field. Call it as often as needed.

Source

pub fn changed(self, from: impl Into<Json>, to: impl Into<Json>) -> Builder

The before and after of a change, as one property each.

Source

pub fn entry(&self) -> &Entry

The entry as it stands, without writing it. For a test.

Source

pub async fn save(self) -> Result<i64>

Write it.

Source

pub async fn record(self)

Write it, and swallow a failure into a warning.

For a caller on a path that must not fail because the trail is unavailable — a sign-out, say. Losing an entry is bad; refusing to sign somebody out because the audit table is missing is worse, and it is the kind of coupling that takes an application down.

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.