add VmcExtRemote

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-12-30 11:36:41 -05:00
parent 92fdc84506
commit 00db538216

View File

@ -970,3 +970,36 @@ impl MessageBehavior for VmcExtVrm {
return Ok(VmcExtVrm { path, title, hash });
}
}
struct VmcExtRemote {
service: String,
json: String,
}
impl MessageBehavior for VmcExtRemote {
fn to_osc_message(&self) -> OscMessage {
return OscMessage {
addr: String::from("/VMC/Ext/Remote"),
args: vec![
OscType::from(self.service.to_owned()),
OscType::from(self.json.to_owned()),
],
};
}
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
if msg.args.len() != 2 {
return Err(String::from("arg count invalid"));
}
let service: String;
let json: String;
match &msg.args[0] {
OscType::String(s) => service = s.to_owned(),
_ => return Err(String::from("arg type invalid")),
}
match &msg.args[1] {
OscType::String(s) => json = s.to_owned(),
_ => return Err(String::from("arg type invalid")),
}
return Ok(VmcExtRemote { service, json });
}
}