Struct twilight_model::gateway::event::gateway::GatewayEventDeserializer
source · pub struct GatewayEventDeserializer<'a> { /* private fields */ }
Expand description
Deserialize into a GatewayEvent
by knowing its dispatch event type and
opcode.
Implementations§
source§impl<'a> GatewayEventDeserializer<'a>
impl<'a> GatewayEventDeserializer<'a>
sourcepub fn new(op: u8, event_type: Option<&'a str>) -> Self
pub fn new(op: u8, event_type: Option<&'a str>) -> Self
Create a new gateway event deserializer when you already know the opcode and dispatch event type.
sourcepub fn from_json(input: &'a str) -> Option<Self>
pub fn from_json(input: &'a str) -> Option<Self>
Create a gateway event deserializer by scanning the JSON payload for its opcode and dispatch event type.
sourcepub fn into_owned(self) -> GatewayEventDeserializer<'static>
pub fn into_owned(self) -> GatewayEventDeserializer<'static>
Create a deserializer with an owned event type.
This is necessary when using a mutable deserialization library such as
simd-json
.
sourcepub fn into_parts(self) -> (u8, Option<u64>, Option<Cow<'a, str>>)
pub fn into_parts(self) -> (u8, Option<u64>, Option<Cow<'a, str>>)
Consume the deserializer, returning its components.
sourcepub fn event_type(&self) -> Option<&str>
pub fn event_type(&self) -> Option<&str>
Dispatch event type of the payload.
Trait Implementations§
source§impl<'a> Debug for GatewayEventDeserializer<'a>
impl<'a> Debug for GatewayEventDeserializer<'a>
source§impl<'de> DeserializeSeed<'de> for GatewayEventDeserializer<'_>
impl<'de> DeserializeSeed<'de> for GatewayEventDeserializer<'_>
§type Value = GatewayEvent
type Value = GatewayEvent
The type produced by using this seed.
source§fn deserialize<D: Deserializer<'de>>(
self,
deserializer: D
) -> Result<Self::Value, D::Error>
fn deserialize<D: Deserializer<'de>>( self, deserializer: D ) -> Result<Self::Value, D::Error>
Equivalent to the more common
Deserialize::deserialize
method, except
with some initial piece of data (the seed) passed in.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§
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