small style changes

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

View File

@ -136,7 +136,7 @@ impl VmcMessage for VmcExtOk {
return OscMessage { addr, args };
}
fn from_osc_message(msg: OscMessage) -> Result<Box<dyn VmcMessage>, FromMessageErr> {
let mut result = VmcExtOk {
let mut result = Self {
loaded: -1,
calibration_state: None,
calibration_mode: None,
@ -194,8 +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::new(result);
return Ok(boxed_result);
return Ok(Box::new(result));
}
fn get_addr(&self) -> String {
return String::from("/VMC/Ext/OK");
@ -239,8 +238,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::new(msg.ok().unwrap());
return Ok(boxed_result);
return Ok(Box::new(msg.ok().unwrap()));
}
return Err(msg.err().unwrap());
}
@ -267,8 +265,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::new(VmcExtT{time});
return Ok(boxed_result);
return Ok(Box::new(Self{time}));
}
fn get_addr(&self) -> String {
return String::from("/VMC/Ext/T");
@ -282,8 +279,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::new(msg.ok().unwrap());
return Ok(boxed_result);
return Ok(Box::new(msg.ok().unwrap()));
}
return Err(msg.err().unwrap());
}
@ -324,7 +320,7 @@ impl VmcMessage for VmcExtRootPos {
return OscMessage { addr, args };
}
fn from_osc_message(msg: OscMessage) -> Result<Box<dyn VmcMessage>, FromMessageErr> {
let mut result: VmcExtRootPos;
let mut result: Self;
if msg.args.len() == 8 || msg.args.len() == 14 {
let mut origin = Vector3::new(0.0, 0.0, 0.0);
let name: String;
@ -411,8 +407,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::new(result);
return Ok(boxed_result);
return Ok(Box::new(result));
}
fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Root/Pos");
@ -432,8 +427,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::new(message.ok().unwrap());
return Ok(boxed_result);
return Ok(Box::new(message.ok().unwrap()));
}
return Err(message.err().unwrap());
}
@ -506,11 +500,10 @@ 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::new(VmcExtBonePos {
return Ok(Box::new(Self {
name,
transform: Transform3D::new(Basis::from_quat(quat), origin),
});
return Ok(boxed_result);
}));
}
fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Bone/Pos");
@ -524,8 +517,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::new(message.ok().unwrap());
return Ok(boxed_result);
return Ok(Box::new(message.ok().unwrap()));
}
return Err(message.err().unwrap());
}
@ -561,8 +553,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::new(VmcExtBlendVal { name, value });
return Ok(boxed_result);
return Ok(Box::new(Self { name, value }));
}
fn get_addr(&self) -> String {
return String::from("/VMC/Ext/Blend/Val");
@ -765,7 +756,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})),
}
return Ok(Box::new(VmcExtCon {
return Ok(Box::new(Self {
active,
name,
is_left,