[][src]Struct twilight_model::gateway::event::gateway::GatewayEventDeserializer

pub struct GatewayEventDeserializer<'a> { /* fields omitted */ }

A deserializer that deserializes into a GatewayEvent by borrowing some bits of scanned information before the actual deserialisation.

This is the borrowed version of GatewayEventDeserializerOwned.

You should use this if you're using an immutable deserialization library like serde_json.

Implementations

impl<'a> GatewayEventDeserializer<'a>[src]

pub fn new(op: u8, sequence: Option<u64>, event_type: Option<&'a str>) -> Self[src]

Create a new gateway event deserializer when you already know the event type and opcode.

This might be useful if you scan the payload for this information and do some work with the event type prior to deserializing the payload.

pub fn from_json(input: &'a str) -> Option<Self>[src]

Create a gateway event deserializer with some information found by scanning the JSON payload to deserialise.

This will scan the payload for the opcode and, optionally, event type if provided. The opcode key ("op"), must be in the payload while the event type key ("t") is optional and only required for event ops.

pub fn event_type_ref(&self) -> Option<&str>[src]

Return an immutable reference to the event type of the payload.

pub fn op(&self) -> u8[src]

Return the opcode of the payload.

pub fn sequence(&self) -> Option<u64>[src]

Return the sequence of the payload.

pub fn into_parts(self) -> (u8, Option<u64>, Option<&'a str>)[src]

Consume the deserializer, returning its opcode and event type components.

Trait Implementations

impl<'a> Clone for GatewayEventDeserializer<'a>[src]

impl<'a> Debug for GatewayEventDeserializer<'a>[src]

impl<'de> DeserializeSeed<'de> for GatewayEventDeserializer<'_>[src]

type Value = GatewayEvent

The type produced by using this seed.

impl<'a> Eq for GatewayEventDeserializer<'a>[src]

impl<'a> PartialEq<GatewayEventDeserializer<'a>> for GatewayEventDeserializer<'a>[src]

impl<'a> StructuralEq for GatewayEventDeserializer<'a>[src]

impl<'a> StructuralPartialEq for GatewayEventDeserializer<'a>[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.