use custom errors in VmcExtSetPeriod
This commit is contained in:
		
							parent
							
								
									78a03b862d
								
							
						
					
					
						commit
						9aa00b5b36
					
				
							
								
								
									
										16
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/lib.rs
									
									
									
									
									
								
							| 
						 | 
					@ -1263,9 +1263,9 @@ impl MessageBehavior for VmcExtSetPeriod {
 | 
				
			||||||
            OscType::from(self.devices),
 | 
					            OscType::from(self.devices),
 | 
				
			||||||
        ] };
 | 
					        ] };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
 | 
					    fn from_osc_message(msg: OscMessage) -> Result<Self, FromMessageErr> {
 | 
				
			||||||
        if msg.args.len() != 6 {
 | 
					        if msg.args.len() != 6 {
 | 
				
			||||||
            return Err(String::from("arg count invalid"));
 | 
					            return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![6], actual: msg.args.len(), addr: msg.addr}));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        let status: i32;
 | 
					        let status: i32;
 | 
				
			||||||
        let root: i32;
 | 
					        let root: i32;
 | 
				
			||||||
| 
						 | 
					@ -1275,27 +1275,27 @@ impl MessageBehavior for VmcExtSetPeriod {
 | 
				
			||||||
        let devices: i32;
 | 
					        let devices: i32;
 | 
				
			||||||
        match msg.args[0] {
 | 
					        match msg.args[0] {
 | 
				
			||||||
            OscType::Int(i) => status = i,
 | 
					            OscType::Int(i) => status = i,
 | 
				
			||||||
            _ => return Err(String::from("arg type invalid"))
 | 
					            _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[0], addr: msg.addr, arg_count: 0}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        match msg.args[1] {
 | 
					        match msg.args[1] {
 | 
				
			||||||
            OscType::Int(i) => root = i,
 | 
					            OscType::Int(i) => root = i,
 | 
				
			||||||
            _ => return Err(String::from("arg type invalid"))
 | 
					            _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[1], addr: msg.addr, arg_count: 1}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        match msg.args[2] {
 | 
					        match msg.args[2] {
 | 
				
			||||||
            OscType::Int(i) => bone = i,
 | 
					            OscType::Int(i) => bone = i,
 | 
				
			||||||
            _ => return Err(String::from("arg type invalid"))
 | 
					            _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[2], addr: msg.addr, arg_count: 2}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        match msg.args[3] {
 | 
					        match msg.args[3] {
 | 
				
			||||||
            OscType::Int(i) => blendshape = i,
 | 
					            OscType::Int(i) => blendshape = i,
 | 
				
			||||||
            _ => return Err(String::from("arg type invalid"))
 | 
					            _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[3], addr: msg.addr, arg_count: 3}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        match msg.args[4] {
 | 
					        match msg.args[4] {
 | 
				
			||||||
            OscType::Int(i) => camera = i,
 | 
					            OscType::Int(i) => camera = i,
 | 
				
			||||||
            _ => return Err(String::from("arg type invalid"))
 | 
					            _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[4], addr: msg.addr, arg_count: 4}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        match msg.args[5] {
 | 
					        match msg.args[5] {
 | 
				
			||||||
            OscType::Int(i) => devices = i,
 | 
					            OscType::Int(i) => devices = i,
 | 
				
			||||||
            _ => return Err(String::from("arg type invalid"))
 | 
					            _ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Int(0)], actual: msg.args[5], addr: msg.addr, arg_count: 5}))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return Ok(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices})
 | 
					        return Ok(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices})
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user