diff --git a/src/model/application/component.rs b/src/model/application/component.rs index 49225611134..51033ef78c6 100644 --- a/src/model/application/component.rs +++ b/src/model/application/component.rs @@ -1,8 +1,10 @@ use serde::de::{Deserialize, Deserializer, Error as DeError}; use serde::ser::{Serialize, Serializer}; -use crate::json::{from_value, JsonMap, Value}; +use crate::internal::prelude::*; +use crate::json::from_value; use crate::model::channel::ReactionType; +use crate::model::utils::deserialize_val; /// The type of a component #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] @@ -44,39 +46,27 @@ pub enum ActionRowComponent { } impl<'de> Deserialize<'de> for ActionRowComponent { - fn deserialize>(deserializer: D) -> Result { - let map = JsonMap::deserialize(deserializer)?; - - let kind = map - .get("type") - .ok_or_else(|| DeError::custom("expected type")) - .and_then(ComponentType::deserialize) - .map_err(DeError::custom)?; - - match kind { - ComponentType::Button => from_value::