add VmcExtOpt

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-12-30 11:40:04 -05:00
parent 00db538216
commit c274f7925b

View File

@ -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<Self, String> {
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")),
}
}
}