small style changes

This commit is contained in:
Cassandra de la Cruz-Munoz 2024-01-01 12:32:38 -05:00
parent c1d21415ba
commit c3193e2fbc
Signed by: cassdlcm
GPG Key ID: BFEBACEA812DDA70

View File

@ -567,8 +567,7 @@ impl VmcExtBlendVal {
pub fn new_vmc_message(name: String, value: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> { pub fn new_vmc_message(name: String, value: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, value); let message = Self::new(name, value);
if message.is_ok() { if message.is_ok() {
let boxed_result = Box::new(message.ok().unwrap()); return Ok(Box::new(message.ok().unwrap()));
return Ok(boxed_result);
} }
return Err(message.err().unwrap()); return Err(message.err().unwrap());
} }
@ -643,12 +642,11 @@ impl VmcMessage for VmcExtCam {
OscType::Float(f) => fov = f, OscType::Float(f) => fov = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[8].to_owned(), addr: msg.addr, arg_count: 8})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[8].to_owned(), addr: msg.addr, arg_count: 8})),
} }
let boxed_result = Box::new(VmcExtCam { return Ok(Box::new(Self {
name, name,
transform: Transform3D::new(Basis::from_quat(quat), origin), transform: Transform3D::new(Basis::from_quat(quat), origin),
fov, fov,
}); }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Cam"); return String::from("/VMC/Ext/Cam");
@ -662,8 +660,7 @@ impl VmcExtCam {
pub fn new_vmc_message(name: String, transform: Transform3D, fov: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> { pub fn new_vmc_message(name: String, transform: Transform3D, fov: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, transform, fov); let message = Self::new(name, transform, fov);
if message.is_ok() { if message.is_ok() {
let boxed_result = Box::new(message.ok().unwrap()); return Ok(Box::new(message.ok().unwrap()));
return Ok(boxed_result);
} }
return Err(message.err().unwrap()); return Err(message.err().unwrap());
} }
@ -836,12 +833,11 @@ impl VmcMessage for VmcExtKey {
OscType::Int(i) => keycode = i, OscType::Int(i) => keycode = i,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[2].to_owned(), addr: msg.addr, arg_count: 2})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[2].to_owned(), addr: msg.addr, arg_count: 2})),
} }
let boxed_result = Box::new(VmcExtKey { return Ok(Box::new(Self {
active, active,
name, name,
keycode, keycode,
}); }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Key"); return String::from("/VMC/Ext/Key");
@ -906,13 +902,12 @@ impl VmcMessage for VmcExtMidiNote {
OscType::Float(f) => velocity = f, OscType::Float(f) => velocity = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})),
} }
let boxed_result = Box::new(VmcExtMidiNote { return Ok(Box::new(Self {
active, active,
channel, channel,
note, note,
velocity, velocity,
}); }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Midi/Note"); return String::from("/VMC/Ext/Midi/Note");
@ -946,8 +941,7 @@ impl VmcMessage for VmcExtMidiCcVal {
OscType::Float(f) => value = f, OscType::Float(f) => value = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})),
} }
let boxed_result = Box::new(VmcExtMidiCcVal { knob, value }); return Ok(Box::new(Self { knob, value }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Midi/CC/Val"); return String::from("/VMC/Ext/Midi/CC/Val");
@ -995,8 +989,7 @@ impl VmcMessage for VmcExtMidiCcBit {
} }
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})),
} }
let boxed_result = Box::new(VmcExtMidiCcBit { knob, active }); return Ok(Box::new(Self { knob, active }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Midi/CC/Bit"); return String::from("/VMC/Ext/Midi/CC/Bit");
@ -1066,12 +1059,11 @@ impl VmcMessage for DeviceTranform {
OscType::Float(f) => quat.w = f, OscType::Float(f) => quat.w = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[7].to_owned(), addr: msg.addr, arg_count: 7})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[7].to_owned(), addr: msg.addr, arg_count: 7})),
} }
let boxed_result = Box::new(DeviceTranform { return Ok(Box::new(Self {
addr: msg.addr.to_owned(), addr: msg.addr.to_owned(),
serial, serial,
transform: Transform3D::new(Basis::from_quat(quat), origin), transform: Transform3D::new(Basis::from_quat(quat), origin),
}); }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return self.addr.to_owned(); return self.addr.to_owned();
@ -1137,12 +1129,11 @@ impl VmcMessage for VmcExtRvc {
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[2].to_owned(), addr: msg.addr, arg_count: 2})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[2].to_owned(), addr: msg.addr, arg_count: 2})),
} }
} }
let boxed_result = Box::new(VmcExtRvc { return Ok(Box::new(Self {
enable, enable,
port, port,
ip_addr, ip_addr,
}); }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Rvc"); return String::from("/VMC/Ext/Rvc");
@ -1233,12 +1224,11 @@ impl VmcMessage for VmcExtLight {
OscType::Float(f) => color.a = f, OscType::Float(f) => color.a = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[11].to_owned(), addr: msg.addr, arg_count: 11})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[11].to_owned(), addr: msg.addr, arg_count: 11})),
} }
let boxed_result = Box::new(VmcExtLight { return Ok(Box::new(Self {
name, name,
transform: Transform3D::new(Basis::from_quat(quat), origin), transform: Transform3D::new(Basis::from_quat(quat), origin),
color, color,
}); }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Light"); return String::from("/VMC/Ext/Light");
@ -1287,8 +1277,7 @@ impl VmcMessage for VmcExtVrm {
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[2].to_owned(), addr: msg.addr, arg_count: 2})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[2].to_owned(), addr: msg.addr, arg_count: 2})),
} }
} }
let boxed_result = Box::new(VmcExtVrm { path, title, hash }); return Ok(Box::new(Self { path, title, hash }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/Vmc/Ext/VRM"); return String::from("/Vmc/Ext/VRM");
@ -1325,8 +1314,7 @@ impl VmcMessage for VmcExtRemote {
OscType::String(s) => json = s.to_owned(), OscType::String(s) => json = s.to_owned(),
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})),
} }
let boxed_result = Box::new(VmcExtRemote{ service, json }); return Ok(Box::new(Self{ service, json }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Remote"); return String::from("/VMC/Ext/Remote");
@ -1356,8 +1344,7 @@ impl VmcMessage for VmcExtOpt {
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})),
} }
let boxed_result = Box::new(VmcExtOpt{option}); return Ok(Box::new(Self{option}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Opt"); return String::from("/VMC/Ext/Opt");
@ -1402,8 +1389,7 @@ impl VmcMessage for VmcExtSettingColor {
OscType::Float(f) => color.a = f, OscType::Float(f) => color.a = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})),
} }
let boxed_result = Box::new(VmcExtSettingColor{color}); return Ok(Box::new(Self{color}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Setting/Color"); return String::from("/VMC/Ext/Setting/Color");
@ -1478,8 +1464,7 @@ impl VmcMessage for VmcExtSettingWin {
OscType::Int(i) => result.hide_border = i, OscType::Int(i) => result.hide_border = i,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})),
} }
let boxed_result = Box::new(result); return Ok(Box::new(result));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Setting/Win"); return String::from("/VMC/Ext/Setting/Win");
@ -1507,8 +1492,7 @@ impl VmcMessage for VmcExtConfig {
OscType::String(s) => path = s.to_owned(), OscType::String(s) => path = s.to_owned(),
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})), _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})),
} }
let boxed_result = Box::new(VmcExtConfig{path}); return Ok(Box::new(Self{path}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Config"); return String::from("/VMC/Ext/Config");
@ -1557,8 +1541,7 @@ impl VmcMessage for VmcThru {
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0), OscType::Float(0.0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1})) _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0), OscType::Float(0.0)], actual: msg.args[1].to_owned(), addr: msg.addr, arg_count: 1}))
} }
} }
let boxed_result = Box::new(VmcThru { addr: msg.addr, arg1 , arg2 }); return Ok(Box::new(Self { addr: msg.addr, arg1 , arg2 }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return self.addr.to_owned(); return self.addr.to_owned();
@ -1620,8 +1603,7 @@ impl VmcMessage for VmcExtSetPeriod {
OscType::Int(i) => devices = i, OscType::Int(i) => devices = i,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[5].to_owned(), addr: msg.addr, arg_count: 5})) _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[5].to_owned(), addr: msg.addr, arg_count: 5}))
} }
let boxed_result = Box::new(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices}); return Ok(Box::new(Self { status, root, bone, blendshape, camera, devices}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Set/Period"); return String::from("/VMC/Ext/Set/Period");
@ -1669,8 +1651,7 @@ impl VmcMessage for VmcExtSetEye {
OscType::Float(f) => z = f, OscType::Float(f) => z = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3})) _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3].to_owned(), addr: msg.addr, arg_count: 3}))
} }
let boxed_result = Box::new(VmcExtSetEye { enable, position: Vector3::new(x, y, z)}); return Ok(Box::new(VmcExtSetEye { enable, position: Vector3::new(x, y, z)}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Set/Eye"); return String::from("/VMC/Ext/Set/Eye");
@ -1695,8 +1676,7 @@ impl VmcMessage for VmcExtSetRes {
OscType::String(s) => response = s.to_owned(), OscType::String(s) => response = s.to_owned(),
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})) _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0}))
} }
let boxed_result = Box::new(VmcExtSetRes{response}); return Ok(Box::new(Self{response}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Set/Res"); return String::from("/VMC/Ext/Set/Res");
@ -1721,8 +1701,7 @@ impl VmcMessage for VmcExtSetCalibExec {
OscType::Int(i) => mode = i, OscType::Int(i) => mode = i,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})) _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0}))
} }
let boxed_result = Box::new(VmcExtSetCalibExec{mode}); return Ok(Box::new(Self{mode}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Set/Calib/Exec"); return String::from("/VMC/Ext/Set/Calib/Exec");
@ -1747,8 +1726,7 @@ impl VmcMessage for VmcExtSetConfig {
OscType::String(s) => path = s.to_owned(), OscType::String(s) => path = s.to_owned(),
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})) _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::String(String::new())], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0}))
} }
let boxed_result = Box::new(VmcExtSetConfig{path}); return Ok(Box::new(Self{path}));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Set/Res"); return String::from("/VMC/Ext/Set/Res");
@ -1768,8 +1746,7 @@ impl VmcMessage for VmcMessageNoArgs {
if msg.args.len() != 0 { if msg.args.len() != 0 {
return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![0], actual: msg.args.len(), addr: msg.addr})) return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![0], actual: msg.args.len(), addr: msg.addr}))
} }
let boxed_result = Box::new(VmcMessageNoArgs { addr: msg.addr }); return Ok(Box::new(Self { addr: msg.addr }));
return Ok(boxed_result);
} }
fn get_addr(&self) -> String { fn get_addr(&self) -> String {
return self.addr.to_owned(); return self.addr.to_owned();