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
impl Builder
Sourcepub fn by(self, id: i64, name: impl Into<String>) -> Builder
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.
Sourcepub fn named(self, name: impl Into<String>) -> Builder
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.
Sourcepub fn on(self, kind: impl Into<String>, id: impl Display) -> Builder
pub fn on(self, kind: impl Into<String>, id: impl Display) -> Builder
What was acted on: a type name and its key.
Sourcepub fn describe(self, description: impl Into<String>) -> Builder
pub fn describe(self, description: impl Into<String>) -> Builder
The sentence somebody will read on the audit page.
pub fn from_ip(self, ip: impl Into<String>) -> Builder
pub fn user_agent(self, agent: impl Into<String>) -> Builder
Sourcepub fn with(self, key: &str, value: impl Into<Json>) -> Builder
pub fn with(self, key: &str, value: impl Into<Json>) -> Builder
One extra field. Call it as often as needed.
Sourcepub fn changed(self, from: impl Into<Json>, to: impl Into<Json>) -> Builder
pub fn changed(self, from: impl Into<Json>, to: impl Into<Json>) -> Builder
The before and after of a change, as one property each.
Sourcepub async fn record(self)
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.