From c274f7925bf05d8cac3cbb4338811d51c4b608aa Mon Sep 17 00:00:00 2001 From: Cassandra de la Cruz-Munoz Date: Sat, 30 Dec 2023 11:40:04 -0500 Subject: [PATCH] add VmcExtOpt --- src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2964850..2015434 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1003,3 +1003,29 @@ impl MessageBehavior for VmcExtRemote { return Ok(VmcExtRemote { service, json }); } } + +struct VmcExtOpt { + option: String, +} + +impl MessageBehavior for VmcExtOpt { + fn to_osc_message(&self) -> OscMessage { + return OscMessage { + addr: String::from("/VMC/Ext/Opt"), + args: vec![OscType::from(self.option.to_owned())], + }; + } + fn from_osc_message(msg: OscMessage) -> Result { + if msg.args.len() != 1 { + return Err(String::from("arg count invalid")); + } + match &msg.args[0] { + OscType::String(s) => { + return Ok(VmcExtOpt { + option: s.to_owned(), + }) + } + _ => return Err(String::from("arg type invalid")), + } + } +}