create constructors for VmcExtCam, remove unneded type hints

This commit is contained in:
Cassandra de la Cruz-Munoz 2024-01-01 12:13:45 -05:00
parent 2c5f0b8f3a
commit d78afe2234
Signed by: cassdlcm
GPG Key ID: BFEBACEA812DDA70

View File

@ -194,7 +194,7 @@ impl VmcMessage for VmcExtOk {
return Err(FromMessageErr::IntRange(FromIntRangeErr { expected_lower: 0, expected_upper: 1, actual: result.loaded, addr: msg.addr, arg_count: 3}));
}
}
let boxed_result: Box<dyn VmcMessage> = Box::new(result);
let boxed_result = Box::new(result);
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -239,7 +239,7 @@ impl VmcExtOk {
pub fn new_vmc_message(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let msg = Self::new(loaded, calibration_state, calibration_mode, tracking_status);
if msg.is_ok() {
let boxed_result: Box<dyn VmcMessage> = Box::new(msg.ok().unwrap());
let boxed_result = Box::new(msg.ok().unwrap());
return Ok(boxed_result);
}
return Err(msg.err().unwrap());
@ -267,7 +267,7 @@ impl VmcMessage for VmcExtT {
OscType::Float(f) => time = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[0].to_owned(), addr: msg.addr, arg_count: 0})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtT{time});
let boxed_result = Box::new(VmcExtT{time});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -282,7 +282,7 @@ impl VmcExtT {
pub fn new_vmc_message(time: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let msg = Self::new(time);
if msg.is_ok() {
let boxed_result: Box<dyn VmcMessage> = Box::new(msg.ok().unwrap());
let boxed_result = Box::new(msg.ok().unwrap());
return Ok(boxed_result);
}
return Err(msg.err().unwrap());
@ -411,7 +411,7 @@ impl VmcMessage for VmcExtRootPos {
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[13].to_owned(), addr: msg.addr, arg_count: 13})),
}
}
let boxed_result: Box<dyn VmcMessage> = Box::new(result);
let boxed_result = Box::new(result);
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -432,7 +432,7 @@ impl VmcExtRootPos {
pub fn new_vmc_message(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, transform, mr_scale, mr_offset);
if message.is_ok() {
let boxed_result: Box<dyn VmcMessage> = Box::new(message.ok().unwrap());
let boxed_result = Box::new(message.ok().unwrap());
return Ok(boxed_result);
}
return Err(message.err().unwrap());
@ -506,7 +506,7 @@ impl VmcMessage for VmcExtBonePos {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtBonePos {
let boxed_result = Box::new(VmcExtBonePos {
name,
transform: Transform3D::new(Basis::from_quat(quat), origin),
});
@ -524,7 +524,7 @@ impl VmcExtBonePos {
pub fn new_vmc_message(name: String, transform: Transform3D) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, transform);
if message.is_ok() {
let boxed_result: Box<dyn VmcMessage> = Box::new(message.ok().unwrap());
let boxed_result = Box::new(message.ok().unwrap());
return Ok(boxed_result);
}
return Err(message.err().unwrap());
@ -561,7 +561,7 @@ impl VmcMessage for VmcExtBlendVal {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtBlendVal { name, value });
let boxed_result = Box::new(VmcExtBlendVal { name, value });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -576,7 +576,7 @@ impl VmcExtBlendVal {
pub fn new_vmc_message(name: String, value: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, value);
if message.is_ok() {
let boxed_result: Box<dyn VmcMessage> = Box::new(message.ok().unwrap());
let boxed_result = Box::new(message.ok().unwrap());
return Ok(boxed_result);
}
return Err(message.err().unwrap());
@ -584,7 +584,7 @@ impl VmcExtBlendVal {
}
#[derive(Debug)]
struct VmcExtCam {
pub struct VmcExtCam {
name: String,
transform: Transform3D,
fov: f32,
@ -652,7 +652,7 @@ impl VmcMessage for VmcExtCam {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtCam {
let boxed_result = Box::new(VmcExtCam {
name,
transform: Transform3D::new(Basis::from_quat(quat), origin),
fov,
@ -664,6 +664,20 @@ impl VmcMessage for VmcExtCam {
}
}
impl VmcExtCam {
pub fn new(name: String, transform: Transform3D, fov: f32) ->Result<VmcExtCam, MessageCreationErr> {
return Ok(Self{name, transform, fov})
}
pub fn new_vmc_message(name: String, transform: Transform3D, fov: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, transform, fov);
if message.is_ok() {
let boxed_result = Box::new(message.ok().unwrap());
return Ok(boxed_result);
}
return Err(message.err().unwrap());
}
}
#[derive(Debug)]
struct VmcExtCon {
active: i32,
@ -734,7 +748,7 @@ impl VmcMessage for VmcExtCon {
OscType::Float(f) => axis.z = f,
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[6].to_owned(), addr: msg.addr, arg_count: 6})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtCon {
let boxed_result = Box::new(VmcExtCon {
active,
name,
is_left,
@ -799,7 +813,7 @@ impl VmcMessage for VmcExtKey {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtKey {
let boxed_result = Box::new(VmcExtKey {
active,
name,
keycode,
@ -869,7 +883,7 @@ impl VmcMessage for VmcExtMidiNote {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtMidiNote {
let boxed_result = Box::new(VmcExtMidiNote {
active,
channel,
note,
@ -909,7 +923,7 @@ impl VmcMessage for VmcExtMidiCcVal {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtMidiCcVal { knob, value });
let boxed_result = Box::new(VmcExtMidiCcVal { knob, value });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -958,7 +972,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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtMidiCcBit { knob, active });
let boxed_result = Box::new(VmcExtMidiCcBit { knob, active });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1029,7 +1043,7 @@ impl VmcMessage for DeviceTranform {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(DeviceTranform {
let boxed_result = Box::new(DeviceTranform {
addr: msg.addr.to_owned(),
serial,
transform: Transform3D::new(Basis::from_quat(quat), origin),
@ -1100,7 +1114,7 @@ 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})),
}
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtRvc {
let boxed_result = Box::new(VmcExtRvc {
enable,
port,
ip_addr,
@ -1196,7 +1210,7 @@ impl VmcMessage for VmcExtLight {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtLight {
let boxed_result = Box::new(VmcExtLight {
name,
transform: Transform3D::new(Basis::from_quat(quat), origin),
color,
@ -1250,7 +1264,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})),
}
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtVrm { path, title, hash });
let boxed_result = Box::new(VmcExtVrm { path, title, hash });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1288,7 +1302,7 @@ impl VmcMessage for VmcExtRemote {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtRemote{ service, json });
let boxed_result = Box::new(VmcExtRemote{ service, json });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1319,7 +1333,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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtOpt{option});
let boxed_result = Box::new(VmcExtOpt{option});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1365,7 +1379,7 @@ impl VmcMessage for VmcExtSettingColor {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtSettingColor{color});
let boxed_result = Box::new(VmcExtSettingColor{color});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1441,7 +1455,7 @@ impl VmcMessage for VmcExtSettingWin {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(result);
let boxed_result = Box::new(result);
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1470,7 +1484,7 @@ impl VmcMessage for VmcExtConfig {
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})),
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtConfig{path});
let boxed_result = Box::new(VmcExtConfig{path});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1520,7 +1534,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}))
}
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcThru { addr: msg.addr, arg1 , arg2 });
let boxed_result = Box::new(VmcThru { addr: msg.addr, arg1 , arg2 });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1583,7 +1597,7 @@ impl VmcMessage for VmcExtSetPeriod {
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}))
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices});
let boxed_result = Box::new(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1632,7 +1646,7 @@ impl VmcMessage for VmcExtSetEye {
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}))
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtSetEye { enable, position: Vector3::new(x, y, z)});
let boxed_result = Box::new(VmcExtSetEye { enable, position: Vector3::new(x, y, z)});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1658,7 +1672,7 @@ impl VmcMessage for VmcExtSetRes {
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}))
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtSetRes{response});
let boxed_result = Box::new(VmcExtSetRes{response});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1684,7 +1698,7 @@ impl VmcMessage for VmcExtSetCalibExec {
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}))
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtSetCalibExec{mode});
let boxed_result = Box::new(VmcExtSetCalibExec{mode});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1710,7 +1724,7 @@ impl VmcMessage for VmcExtSetConfig {
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}))
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcExtSetConfig{path});
let boxed_result = Box::new(VmcExtSetConfig{path});
return Ok(boxed_result);
}
fn get_addr(&self) -> String {
@ -1731,7 +1745,7 @@ impl VmcMessage for VmcMessageNoArgs {
if msg.args.len() != 0 {
return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![0], actual: msg.args.len(), addr: msg.addr}))
}
let boxed_result: Box<dyn VmcMessage> = Box::new(VmcMessageNoArgs { addr: msg.addr });
let boxed_result = Box::new(VmcMessageNoArgs { addr: msg.addr });
return Ok(boxed_result);
}
fn get_addr(&self) -> String {