Function twilight_gateway::parse
source · pub fn parse(
event: String,
wanted_event_types: EventTypeFlags
) -> Result<Option<GatewayEvent>, ReceiveMessageError>
Expand description
Parse a JSON encoded event into a gateway event if its type is in
wanted_event_types
.
This function can be used together with Shard::next_message
for greater
control of the deserialization process without giving up the ease of use of
Shard::next_event
.
Returns None
if the event type is not contained inside of
wanted_event_types
.
Errors
Returns a ReceiveMessageErrorType::Deserializing
error if the event
could not be deserialized.