create constructors for VmcExtBlendVal

This commit is contained in:
Cassandra de la Cruz-Munoz 2024-01-01 12:07:54 -05:00
parent be4d54e34c
commit 44608ba082
Signed by: cassdlcm
GPG Key ID: BFEBACEA812DDA70

View File

@ -217,7 +217,7 @@ impl VmcExtOk {
if tracking_status.is_some() && (tracking_status.unwrap() < 0 || tracking_status.unwrap() > 1) {
return Err(MessageCreationErr::IntRange(CreateIntRangeErr { expected_lower: 0, expected_upper: 1, actual: loaded, calling_func: String::from("VmcExtOk::new"), arg_name: String::from("tracking_status")}));
}
return Ok(VmcExtOk { loaded, calibration_state, calibration_mode, tracking_status})
return Ok(Self { loaded, calibration_state, calibration_mode, tracking_status})
}
if calibration_state.is_some() && tracking_status.is_none() {
return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("calibration_state, calibration_mode"), String::from("calibration_state, calibration_mode, tracking_status")], actual: String::from("calibration_state"), calling_func: String::from("VmcExtOk::new")}))
@ -234,7 +234,7 @@ impl VmcExtOk {
if tracking_status.is_some() {
return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("calibration_state, calibration_mode"), String::from("calibration_state, calibration_mode, tracking_status")], actual: String::from("tracking_status"), calling_func: String::from("VmcExtOk::new")}))
}
return Ok(VmcExtOk { loaded, calibration_state: None, calibration_mode: None, tracking_status: None})
return Ok(Self { loaded, calibration_state: None, calibration_mode: None, tracking_status: None})
}
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);
@ -277,7 +277,7 @@ impl VmcMessage for VmcExtT {
impl VmcExtT {
fn new(time: f32) -> Result<Self, MessageCreationErr> {
return Ok(VmcExtT { time });
return Ok(Self { time });
}
fn new_vmc_message(time: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let msg = Self::new(time);
@ -427,7 +427,7 @@ impl VmcExtRootPos {
if mr_scale.is_none() && mr_offset.is_some() {
return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("mr_scale, mr_offset")], actual: String::from("mr_offset"), calling_func: String::from("VmcExtRootPos::new")}))
}
return Ok(VmcExtRootPos { name, transform, mr_scale, mr_offset});
return Ok(Self { name, transform, mr_scale, mr_offset});
}
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);
@ -519,7 +519,7 @@ impl VmcMessage for VmcExtBonePos {
impl VmcExtBonePos {
fn new(name: String, transform: Transform3D) -> Result<Self, MessageCreationErr> {
return Ok(VmcExtBonePos{name, transform});
return Ok(Self{name, transform});
}
fn new_vmc_message(name: String, transform: Transform3D) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
let message = Self::new(name, transform);
@ -569,6 +569,20 @@ impl VmcMessage for VmcExtBlendVal {
}
}
impl VmcExtBlendVal {
fn new(name: String, value: f32) -> Result<Self, MessageCreationErr> {
return Ok(Self{name, value});
}
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());
return Ok(boxed_result);
}
return Err(message.err().unwrap());
}
}
#[derive(Debug)]
struct VmcExtCam {
name: String,