Buttplug sex toy control library
at master 91 lines 2.5 kB view raw
1use std::cmp::Ordering; 2 3use super::*; 4use crate::message::RequestServerInfoV1; 5use buttplug_core::{ 6 errors::ButtplugMessageError, 7 message::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator, PingV0}, 8}; 9 10use serde::{Deserialize, Serialize}; 11 12/// Represents all client-to-server messages in v0 of the Buttplug Spec 13#[derive( 14 Debug, 15 Clone, 16 PartialEq, 17 ButtplugMessage, 18 ButtplugMessageValidator, 19 ButtplugMessageFinalizer, 20 FromSpecificButtplugMessage, 21 Serialize, 22 Deserialize, 23)] 24pub enum ButtplugClientMessageV0 { 25 Ping(PingV0), 26 // Handshake messages 27 // 28 // We use RequestServerInfoV1 here, as the only difference between v0 and v1 was passing the spec 29 // version. If the spec version doesn't exist, we automatically set the spec version to 0. 30 RequestServerInfo(RequestServerInfoV1), 31 // Device enumeration messages 32 StartScanning(StartScanningV0), 33 StopScanning(StopScanningV0), 34 RequestDeviceList(RequestDeviceListV0), 35 // Generic commands 36 StopAllDevices(StopAllDevicesV0), 37 StopDeviceCmd(StopDeviceCmdV0), 38 // Deprecated generic commands 39 SingleMotorVibrateCmd(SingleMotorVibrateCmdV0), 40 // Deprecated device specific commands 41 FleshlightLaunchFW12Cmd(FleshlightLaunchFW12CmdV0), 42 VorzeA10CycloneCmd(VorzeA10CycloneCmdV0), 43} 44 45/// Represents all server-to-client messages in v0 of the Buttplug Spec 46#[derive( 47 Debug, 48 Clone, 49 PartialEq, 50 ButtplugMessage, 51 ButtplugMessageValidator, 52 ButtplugMessageFinalizer, 53 Serialize, 54 Deserialize, 55)] 56pub enum ButtplugServerMessageV0 { 57 // Status messages 58 Ok(OkV0), 59 Error(ErrorV0), 60 // Handshake messages 61 ServerInfo(ServerInfoV0), 62 // Device enumeration messages 63 DeviceList(DeviceListV0), 64 DeviceAdded(DeviceAddedV0), 65 DeviceRemoved(DeviceRemovedV0), 66 ScanningFinished(ScanningFinishedV0), 67} 68 69#[derive(Copy, Debug, Clone, PartialEq, Eq, Hash, Display, Serialize, Deserialize)] 70pub enum ButtplugDeviceMessageNameV0 { 71 StopDeviceCmd, 72 // Deprecated generic commands 73 SingleMotorVibrateCmd, 74 // Deprecated device specific commands 75 FleshlightLaunchFW12Cmd, 76 LovenseCmd, 77 KiirooCmd, 78 VorzeA10CycloneCmd, 79} 80 81impl PartialOrd for ButtplugDeviceMessageNameV0 { 82 fn partial_cmp(&self, other: &ButtplugDeviceMessageNameV0) -> Option<Ordering> { 83 Some(self.cmp(other)) 84 } 85} 86 87impl Ord for ButtplugDeviceMessageNameV0 { 88 fn cmp(&self, other: &ButtplugDeviceMessageNameV0) -> Ordering { 89 self.to_string().cmp(&other.to_string()) 90 } 91}