type aliasing and create a few more constructors
This commit is contained in:
		
							parent
							
								
									c3193e2fbc
								
							
						
					
					
						commit
						682591278f
					
				
							
								
								
									
										117
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										117
									
								
								src/lib.rs
									
									
									
									
									
								
							| 
						 | 
					@ -112,6 +112,10 @@ pub enum MessageCreationErr {
 | 
				
			||||||
    OptionalArgs(CreateOptionalArgsErr),
 | 
					    OptionalArgs(CreateOptionalArgsErr),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type MsgNewResult<T> = Result<T, MessageCreationErr>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type TraitMsgNewResult = Result<Box<dyn VmcMessage>, MessageCreationErr>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
pub struct VmcExtOk {
 | 
					pub struct VmcExtOk {
 | 
				
			||||||
    loaded: i32,
 | 
					    loaded: i32,
 | 
				
			||||||
| 
						 | 
					@ -202,7 +206,7 @@ impl VmcMessage for VmcExtOk {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl VmcExtOk {
 | 
					impl VmcExtOk {
 | 
				
			||||||
    pub fn new(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> Result<Self, MessageCreationErr> {
 | 
					    pub fn new(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> MsgNewResult<Self> {
 | 
				
			||||||
        if loaded < 0 || loaded > 1 {
 | 
					        if loaded < 0 || loaded > 1 {
 | 
				
			||||||
            return Err(MessageCreationErr::IntRange(CreateIntRangeErr { expected_lower: 0, expected_upper: 1, actual: loaded, calling_func: String::from("VmcExtOk::new"), arg_name: String::from("loaded")}));
 | 
					            return Err(MessageCreationErr::IntRange(CreateIntRangeErr { expected_lower: 0, expected_upper: 1, actual: loaded, calling_func: String::from("VmcExtOk::new"), arg_name: String::from("loaded")}));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -235,12 +239,12 @@ impl VmcExtOk {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Ok(Self { loaded, calibration_state: None, calibration_mode: None, tracking_status: None})
 | 
					        return Ok(Self { loaded, calibration_state: None, calibration_mode: None, tracking_status: None})
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pub fn new_vmc_message(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
 | 
					    pub fn new_vmc_message(loaded: i32, calibration_state: Option<i32>, calibration_mode: Option<i32>, tracking_status: Option<i32>) -> TraitMsgNewResult {
 | 
				
			||||||
        let msg = Self::new(loaded, calibration_state, calibration_mode, tracking_status);
 | 
					        let msg = Self::new(loaded, calibration_state, calibration_mode, tracking_status);
 | 
				
			||||||
        if msg.is_ok() {
 | 
					        match msg {
 | 
				
			||||||
            return Ok(Box::new(msg.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(msg.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -273,15 +277,15 @@ impl VmcMessage for VmcExtT {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl VmcExtT {
 | 
					impl VmcExtT {
 | 
				
			||||||
    pub fn new(time: f32) -> Result<Self, MessageCreationErr> {
 | 
					    pub fn new(time: f32) -> MsgNewResult<Self> {
 | 
				
			||||||
        return Ok(Self { time });
 | 
					        return Ok(Self { time });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pub fn new_vmc_message(time: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
 | 
					    pub fn new_vmc_message(time: f32) -> TraitMsgNewResult {
 | 
				
			||||||
        let msg = Self::new(time);
 | 
					        let msg = Self::new(time);
 | 
				
			||||||
        if msg.is_ok() {
 | 
					        match msg {
 | 
				
			||||||
            return Ok(Box::new(msg.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(msg.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -415,7 +419,7 @@ impl VmcMessage for VmcExtRootPos {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl VmcExtRootPos {
 | 
					impl VmcExtRootPos {
 | 
				
			||||||
    pub fn new(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Self, MessageCreationErr> {
 | 
					    pub fn new(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> MsgNewResult<Self> {
 | 
				
			||||||
        if mr_scale.is_some() && mr_offset.is_none() {
 | 
					        if mr_scale.is_some() && mr_offset.is_none() {
 | 
				
			||||||
            return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("mr_scale, mr_offset")], actual: String::from("mr_scale"), calling_func: String::from("VmcExtRootPos::new")}));
 | 
					            return Err(MessageCreationErr::OptionalArgs(CreateOptionalArgsErr { expected_sets: vec![String::from("None"), String::from("mr_scale, mr_offset")], actual: String::from("mr_scale"), calling_func: String::from("VmcExtRootPos::new")}));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -424,12 +428,12 @@ impl VmcExtRootPos {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Ok(Self { name, transform, mr_scale, mr_offset});
 | 
					        return Ok(Self { name, transform, mr_scale, mr_offset});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pub fn new_vmc_message(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
 | 
					    pub fn new_vmc_message(name: String, transform: Transform3D, mr_scale: Option<Vector3>, mr_offset: Option<Vector3>) -> TraitMsgNewResult {
 | 
				
			||||||
        let message = Self::new(name, transform, mr_scale, mr_offset);
 | 
					        let message = Self::new(name, transform, mr_scale, mr_offset);
 | 
				
			||||||
        if message.is_ok() {
 | 
					        match message {
 | 
				
			||||||
            return Ok(Box::new(message.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(message.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -511,15 +515,15 @@ impl VmcMessage for VmcExtBonePos {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl VmcExtBonePos {
 | 
					impl VmcExtBonePos {
 | 
				
			||||||
    pub fn new(name: String, transform: Transform3D) -> Result<Self, MessageCreationErr> {
 | 
					    pub fn new(name: String, transform: Transform3D) -> MsgNewResult<Self> {
 | 
				
			||||||
        return Ok(Self{name, transform});
 | 
					        return Ok(Self{name, transform});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pub fn new_vmc_message(name: String, transform: Transform3D) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
 | 
					    pub fn new_vmc_message(name: String, transform: Transform3D) -> TraitMsgNewResult {
 | 
				
			||||||
        let message = Self::new(name, transform);
 | 
					        let message = Self::new(name, transform);
 | 
				
			||||||
        if message.is_ok() {
 | 
					        match message {
 | 
				
			||||||
            return Ok(Box::new(message.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(message.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -561,15 +565,15 @@ impl VmcMessage for VmcExtBlendVal {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl VmcExtBlendVal {
 | 
					impl VmcExtBlendVal {
 | 
				
			||||||
    pub fn new(name: String, value: f32) -> Result<Self, MessageCreationErr> {
 | 
					    pub fn new(name: String, value: f32) -> MsgNewResult<Self> {
 | 
				
			||||||
        return Ok(Self{name, value});
 | 
					        return Ok(Self{name, value});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pub fn new_vmc_message(name: String, value: f32) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
 | 
					    pub fn new_vmc_message(name: String, value: f32) -> TraitMsgNewResult {
 | 
				
			||||||
        let message = Self::new(name, value);
 | 
					        let message = Self::new(name, value);
 | 
				
			||||||
        if message.is_ok() {
 | 
					        match message {
 | 
				
			||||||
            return Ok(Box::new(message.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(message.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -657,12 +661,12 @@ impl VmcExtCam {
 | 
				
			||||||
    pub fn new(name: String, transform: Transform3D, fov: f32) ->Result<VmcExtCam, MessageCreationErr> {
 | 
					    pub fn new(name: String, transform: Transform3D, fov: f32) ->Result<VmcExtCam, MessageCreationErr> {
 | 
				
			||||||
        return Ok(Self{name, transform, fov})
 | 
					        return Ok(Self{name, transform, fov})
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    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) -> TraitMsgNewResult {
 | 
				
			||||||
        let message = Self::new(name, transform, fov);
 | 
					        let message = Self::new(name, transform, fov);
 | 
				
			||||||
        if message.is_ok() {
 | 
					        match message {
 | 
				
			||||||
            return Ok(Box::new(message.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(message.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -767,23 +771,23 @@ impl VmcMessage for VmcExtCon {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl VmcExtCon {
 | 
					impl VmcExtCon {
 | 
				
			||||||
    pub fn new(active: i32, name: String, is_left: bool, is_touch: bool, axis: Vector3) -> Result<Self, MessageCreationErr> {
 | 
					    pub fn new(active: i32, name: String, is_left: bool, is_touch: bool, axis: Vector3) -> MsgNewResult<Self> {
 | 
				
			||||||
        if active > 2 || active < 0 {
 | 
					        if active > 2 || active < 0 {
 | 
				
			||||||
            return Err(MessageCreationErr::IntRange(CreateIntRangeErr { expected_lower: 0, expected_upper: 2, actual: active, calling_func: String::from("VmcExtCon::new"), arg_name: String::from("active")}))
 | 
					            return Err(MessageCreationErr::IntRange(CreateIntRangeErr { expected_lower: 0, expected_upper: 2, actual: active, calling_func: String::from("VmcExtCon::new"), arg_name: String::from("active")}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Ok(Self{ active, name, is_left, is_touch, axis });
 | 
					        return Ok(Self{ active, name, is_left, is_touch, axis });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pub fn new_vmc_message(active: i32, name: String, is_left: bool, is_touch: bool, axis: Vector3) -> Result<Box<dyn VmcMessage>, MessageCreationErr> {
 | 
					    pub fn new_vmc_message(active: i32, name: String, is_left: bool, is_touch: bool, axis: Vector3) -> TraitMsgNewResult {
 | 
				
			||||||
        let message = Self::new(active, name, is_left, is_touch, axis);
 | 
					        let message = Self::new(active, name, is_left, is_touch, axis);
 | 
				
			||||||
        if message.is_ok() {
 | 
					        match message {
 | 
				
			||||||
            return Ok(Box::new(message.ok().unwrap()));
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Err(message.err().unwrap());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
struct VmcExtKey {
 | 
					pub struct VmcExtKey {
 | 
				
			||||||
    active: bool,
 | 
					    active: bool,
 | 
				
			||||||
    name: String,
 | 
					    name: String,
 | 
				
			||||||
    keycode: i32,
 | 
					    keycode: i32,
 | 
				
			||||||
| 
						 | 
					@ -844,8 +848,21 @@ impl VmcMessage for VmcExtKey {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl VmcExtKey {
 | 
				
			||||||
 | 
					    pub fn new(active: bool, name: String, keycode: i32) -> MsgNewResult<Self> {
 | 
				
			||||||
 | 
					        return Ok(Self { active, name, keycode})
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    pub fn new_vmc_message(active: bool, name: String, keycode: i32) -> TraitMsgNewResult {
 | 
				
			||||||
 | 
					        let message = Self::new(active, name, keycode);
 | 
				
			||||||
 | 
					        match message {
 | 
				
			||||||
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
struct VmcExtMidiNote {
 | 
					pub struct VmcExtMidiNote {
 | 
				
			||||||
    active: bool,
 | 
					    active: bool,
 | 
				
			||||||
    channel: i32,
 | 
					    channel: i32,
 | 
				
			||||||
    note: i32,
 | 
					    note: i32,
 | 
				
			||||||
| 
						 | 
					@ -914,8 +931,21 @@ impl VmcMessage for VmcExtMidiNote {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl VmcExtMidiNote {
 | 
				
			||||||
 | 
					    pub fn new(active: bool, channel: i32, note: i32, velocity: f32) -> MsgNewResult<Self> {
 | 
				
			||||||
 | 
					        return Ok(Self { active, channel, note, velocity})
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    pub fn new_vmc_message(active: bool, channel: i32, note: i32, velocity: f32) -> TraitMsgNewResult {
 | 
				
			||||||
 | 
					        let message = Self::new(active, channel, note, velocity);
 | 
				
			||||||
 | 
					        match message {
 | 
				
			||||||
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
struct VmcExtMidiCcVal {
 | 
					pub struct VmcExtMidiCcVal {
 | 
				
			||||||
    knob: i32,
 | 
					    knob: i32,
 | 
				
			||||||
    value: f32,
 | 
					    value: f32,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -948,6 +978,19 @@ impl VmcMessage for VmcExtMidiCcVal {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl VmcExtMidiCcVal {
 | 
				
			||||||
 | 
					    pub fn new(knob: i32, value: f32) -> MsgNewResult<Self> {
 | 
				
			||||||
 | 
					        return Ok(Self { knob, value});
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    pub fn new_vmc_message(knob: i32, value: f32) -> TraitMsgNewResult {
 | 
				
			||||||
 | 
					        let message = Self::new(knob, value);
 | 
				
			||||||
 | 
					        match message {
 | 
				
			||||||
 | 
					            Ok(val) => return Ok(Box::new(val)),
 | 
				
			||||||
 | 
					            Err(val) => return Err(val),
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug)]
 | 
					#[derive(Debug)]
 | 
				
			||||||
struct VmcExtMidiCcBit {
 | 
					struct VmcExtMidiCcBit {
 | 
				
			||||||
    knob: i32,
 | 
					    knob: i32,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user