swayipc_types/error/
command_type.rs

1use crate::{CommandType, Error::InvalidCommandType, Fallible};
2use serde::de::DeserializeOwned as Deserialize;
3
4impl CommandType {
5    pub fn decode<D: Deserialize>(self, (payload_type, payload): (u32, Vec<u8>)) -> Fallible<D> {
6        let command_type = u32::from(self);
7        if payload_type != command_type {
8            return Err(InvalidCommandType(payload_type, command_type));
9        }
10        Ok(serde_json::from_slice(&payload)?)
11    }
12}