Buttplug sex toy control library
at dev 1.3 kB view raw
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::{ButtplugMessage, ButtplugMessageFinalizer, ButtplugMessageValidator}, 11}; 12use getset::Getters; 13use serde::{Deserialize, Serialize}; 14 15#[derive( 16 Debug, 17 Default, 18 ButtplugMessage, 19 ButtplugMessageFinalizer, 20 Clone, 21 PartialEq, 22 Eq, 23 Getters, 24 Serialize, 25 Deserialize, 26)] 27pub struct TestV0 { 28 /// Message Id, used for matching message pairs in remote connection instances. 29 #[serde(rename = "Id")] 30 id: u32, 31 /// Test string, which will be echoed back to client when sent to server. 32 #[serde(rename = "TestString")] 33 #[getset(get = "pub")] 34 test_string: String, 35} 36 37impl TestV0 { 38 /// Creates a new Test message with the given Id. 39 pub fn new(test: &str) -> Self { 40 Self { 41 id: 1, 42 test_string: test.to_owned(), 43 } 44 } 45} 46 47impl ButtplugMessageValidator for TestV0 { 48 fn is_valid(&self) -> Result<(), ButtplugMessageError> { 49 // Test could have any Id. There's really no validity check for this. What a 50 // horrible message. So glad it's deprecated. :| 51 Ok(()) 52 } 53}