[][src]Function serenity::model::event::deserialize_event_with_type

pub fn deserialize_event_with_type(kind: EventType, v: Value) -> Result<Event>

Deserializes a serde_json::Value into an Event.

The given EventType is used to determine what event to deserialize into. For example, an EventType::ChannelCreate will cause the given value to attempt to be deserialized into a ChannelCreateEvent.

Special handling is done in regards to EventType::GuildCreate and EventType::GuildDelete: they check for an "unavailable" key and, if present and containing a value of true, will cause a GuildUnavailableEvent to be returned. Otherwise, all other event types correlate to the deserialization of their appropriate event.