pub struct EventBody {
pub kind: EventKind,
pub payload: Value,
}Expand description
The kind and the payload, as the log holds them.
The pair {"kind": .., "payload": ..}: the kind is the name a payload type
declares, and the payload is that type’s value, held as JSON so that a body
under a kind this crate has never heard of is carried rather than refused.
Fields§
§kind: EventKindWhich event this is.
payload: ValueWhat it carries, in the form its kind declares.
Implementations§
Source§impl EventBody
impl EventBody
Sourcepub fn of<P: EventPayload>(payload: &P) -> Result<Self, Error>
pub fn of<P: EventPayload>(payload: &P) -> Result<Self, Error>
The body of one typed payload, under the kind its type declares.
§Errors
Returns the serialization failure when the payload cannot be rendered
as JSON, which a payload type declared with serde never is.
Sourcepub fn is<P: EventPayload>(&self) -> bool
pub fn is<P: EventPayload>(&self) -> bool
Whether this body is under the kind P declares.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EventBody
impl<'de> Deserialize<'de> for EventBody
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for EventBody
impl JsonSchema for EventBody
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Sample for EventBody
impl Sample for EventBody
Source§fn sample_full() -> Self
fn sample_full() -> Self
A value carrying every field the type declares.
Source§fn sample_minimal() -> Self
fn sample_minimal() -> Self
A value carrying every optional field absent.
Source§fn sample_alternates() -> Vec<Self>
fn sample_alternates() -> Vec<Self>
One value per further arm, for a type whose wire form is a union. Read more
impl StructuralPartialEq for EventBody
Auto Trait Implementations§
impl Freeze for EventBody
impl RefUnwindSafe for EventBody
impl Send for EventBody
impl Sync for EventBody
impl Unpin for EventBody
impl UnsafeUnpin for EventBody
impl UnwindSafe for EventBody
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
Mutably borrows from an owned value. Read more