Buttplug sex toy control library
at dev 1.2 kB view raw
1use super::ServerDeviceMessageAttributesV3; 2use super::v2::ServerDeviceMessageAttributesV2; 3use buttplug_core::errors::ButtplugError; 4use buttplug_server_device_config::ServerDeviceFeature; 5use getset::Getters; 6use std::collections::HashMap; 7 8#[derive(Debug, Getters, Clone)] 9pub(crate) struct ServerDeviceAttributes { 10 /* #[getset(get = "pub")] 11 attrs_v1: ClientDeviceMessageAttributesV1, 12 */ 13 #[getset(get = "pub")] 14 attrs_v2: ServerDeviceMessageAttributesV2, 15 #[getset(get = "pub")] 16 attrs_v3: ServerDeviceMessageAttributesV3, 17 #[getset(get = "pub")] 18 features: Vec<ServerDeviceFeature>, 19} 20 21impl ServerDeviceAttributes { 22 pub fn new(features: &Vec<ServerDeviceFeature>) -> Self { 23 Self { 24 attrs_v3: ServerDeviceMessageAttributesV3::from(features.clone()), 25 attrs_v2: ServerDeviceMessageAttributesV2::from(features.clone()), 26 /* 27 attrs_v1: ClientDeviceMessageAttributesV1::from(features.clone()), 28 */ 29 features: features.clone(), 30 } 31 } 32} 33 34pub(crate) trait TryFromClientMessage<T> 35where 36 Self: Sized, 37{ 38 fn try_from_client_message( 39 msg: T, 40 features: &HashMap<u32, ServerDeviceAttributes>, 41 ) -> Result<Self, ButtplugError>; 42}