Struct HookEvent
pub struct HookEvent {
pub kind: EventKind,
pub custom: Option<String>,
pub header: EventHeader,
pub fields: BTreeMap<String, Value>,
pub cut: Vec<String>,
}Expand description
What an observer receives: a core event with its header and its bounded, scrubbed fields.
Fields§
§kind: EventKindWhich event. EventKind::Custom for an event a tool declared; its name is in
HookEvent::custom.
custom: Option<String>The name of a custom event (demo.published); None for a core event.
header: EventHeaderWho and when.
fields: BTreeMap<String, Value>The event’s fields, by name.
cut: Vec<String>The names of the fields that were cut (or dropped) to keep the bounds.
Implementations§
§impl HookEvent
impl HookEvent
pub fn new(kind: EventKind, header: EventHeader) -> HookEvent
pub fn new(kind: EventKind, header: EventHeader) -> HookEvent
An event of kind with no field yet.
pub fn custom(
name: &str,
version: u32,
header: EventHeader,
data: &Value,
scrub: &dyn Fn(&str) -> String,
) -> HookEvent
pub fn custom( name: &str, version: u32, header: EventHeader, data: &Value, scrub: &dyn Fn(&str) -> String, ) -> HookEvent
A custom event (ADR 0050, slice H5) called name: its version and its data, the data
scrubbed with scrub and held to the JSON bound like any JSON field. A custom event is
always EventKind::Custom; the loop builds one for each event a record holds.
pub fn name(&self) -> &str
pub fn name(&self) -> &str
The event’s name: the catalogue’s for a core event, the declared one for a custom event.
pub fn text(
self,
name: &str,
text: &str,
scrub: &dyn Fn(&str) -> String,
) -> HookEvent
pub fn text( self, name: &str, text: &str, scrub: &dyn Fn(&str) -> String, ) -> HookEvent
The same event with a text field: scrubbed with scrub, then cut at [FIELD_MAX].
pub fn json(
self,
name: &str,
value: &Value,
scrub: &dyn Fn(&str) -> String,
) -> HookEvent
pub fn json( self, name: &str, value: &Value, scrub: &dyn Fn(&str) -> String, ) -> HookEvent
The same event with a JSON field: every string inside (and every key) is scrubbed with
scrub, each is cut at [FIELD_MAX], and a value that serializes past [JSON_MAX] is
replaced by its cut serialization, as text.
pub fn plain(self, name: &str, value: impl Into<Value>) -> HookEvent
pub fn plain(self, name: &str, value: impl Into<Value>) -> HookEvent
The same event with a number or a flag, which need no bound.
pub fn bounded(self) -> HookEvent
pub fn bounded(self) -> HookEvent
The same event held to [EVENT_MAX]: while it serializes past it, the largest field is
dropped (its value becomes null) and named in HookEvent::cut.
Trait Implementations§
impl Eq for HookEvent
impl StructuralPartialEq for HookEvent
Auto Trait Implementations§
impl Freeze for HookEvent
impl RefUnwindSafe for HookEvent
impl Send for HookEvent
impl Sync for HookEvent
impl Unpin for HookEvent
impl UnsafeUnpin for HookEvent
impl UnwindSafe for HookEvent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].