Buttplug sex toy control library
1// Buttplug Rust Source Code File - See https://buttplug.io for more info.
2//
3// Copyright 2016-2024 Nonpolynomial Labs LLC. All rights reserved.
4//
5// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
6// for full license information.
7
8use buttplug_core::{
9 errors::ButtplugMessageError,
10 message::{
11 ButtplugDeviceMessage,
12 ButtplugMessage,
13 ButtplugMessageFinalizer,
14 ButtplugMessageValidator,
15 InputType,
16 },
17};
18use getset::Getters;
19use serde::{Deserialize, Serialize};
20
21#[derive(
22 Debug,
23 ButtplugDeviceMessage,
24 ButtplugMessageFinalizer,
25 PartialEq,
26 Eq,
27 Clone,
28 Getters,
29 Serialize,
30 Deserialize,
31)]
32pub struct SensorSubscribeCmdV3 {
33 #[serde(rename = "Id")]
34 id: u32,
35 #[serde(rename = "DeviceIndex")]
36 device_index: u32,
37 #[getset(get = "pub")]
38 #[serde(rename = "SensorIndex")]
39 sensor_index: u32,
40 #[getset(get = "pub")]
41 #[serde(rename = "SensorType")]
42 sensor_type: InputType,
43}
44
45impl SensorSubscribeCmdV3 {
46 pub fn new(device_index: u32, sensor_index: u32, sensor_type: InputType) -> Self {
47 Self {
48 id: 1,
49 device_index,
50 sensor_index,
51 sensor_type,
52 }
53 }
54}
55
56impl ButtplugMessageValidator for SensorSubscribeCmdV3 {
57 fn is_valid(&self) -> Result<(), ButtplugMessageError> {
58 self.is_not_system_id(self.id)
59 }
60}