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::message::{
9 ButtplugDeviceMessage,
10 ButtplugMessage,
11 ButtplugMessageFinalizer,
12 ButtplugMessageValidator,
13 InputType,
14};
15use getset::{CopyGetters, Getters};
16use serde::{Deserialize, Serialize};
17
18// This message can have an Id of 0, as it can be emitted as part of a
19// subscription and won't have a matching task Id in that case.
20#[derive(
21 Debug,
22 ButtplugDeviceMessage,
23 ButtplugMessageValidator,
24 ButtplugMessageFinalizer,
25 Clone,
26 Getters,
27 CopyGetters,
28 PartialEq,
29 Eq,
30 Serialize,
31 Deserialize,
32)]
33pub struct SensorReadingV3 {
34 #[serde(rename = "Id")]
35 id: u32,
36 #[serde(rename = "DeviceIndex")]
37 device_index: u32,
38 #[serde(rename = "SensorIndex")]
39 #[getset[get_copy="pub"]]
40 sensor_index: u32,
41 #[serde(rename = "SensorType")]
42 #[getset[get_copy="pub"]]
43 sensor_type: InputType,
44 #[serde(rename = "Data")]
45 #[getset[get="pub"]]
46 data: Vec<i32>,
47}
48
49impl SensorReadingV3 {
50 pub fn new(device_index: u32, sensor_index: u32, sensor_type: InputType, data: Vec<i32>) -> Self {
51 Self {
52 id: 0,
53 device_index,
54 sensor_index,
55 sensor_type,
56 data,
57 }
58 }
59}