Struct twilight_model::gateway::event::gateway::GatewayEventDeserializer [−][src]
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]
fn clone(&self) -> GatewayEventDeserializer<'a>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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.
fn deserialize<D: Deserializer<'de>>(
self,
deserializer: D
) -> Result<Self::Value, D::Error>
[src]
self,
deserializer: D
) -> Result<Self::Value, D::Error>
impl<'a> Eq for GatewayEventDeserializer<'a>
[src]
impl<'a> PartialEq<GatewayEventDeserializer<'a>> for GatewayEventDeserializer<'a>
[src]
fn eq(&self, other: &GatewayEventDeserializer<'a>) -> bool
[src]
fn ne(&self, other: &GatewayEventDeserializer<'a>) -> bool
[src]
impl<'a> StructuralEq for GatewayEventDeserializer<'a>
[src]
impl<'a> StructuralPartialEq for GatewayEventDeserializer<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for GatewayEventDeserializer<'a>
impl<'a> Send for GatewayEventDeserializer<'a>
impl<'a> Sync for GatewayEventDeserializer<'a>
impl<'a> Unpin for GatewayEventDeserializer<'a>
impl<'a> UnwindSafe for GatewayEventDeserializer<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,