custom message parsing errors #1
12
src/lib.rs
12
src/lib.rs
|
@ -1316,9 +1316,9 @@ impl MessageBehavior for VmcExtSetEye {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
|
fn from_osc_message(msg: OscMessage) -> Result<Self, FromMessageErr> {
|
||||||
if msg.args.len() != 4 {
|
if msg.args.len() != 4 {
|
||||||
return Err(String::from("arg count invalid"));
|
return Err(FromMessageErr::ArgCount(ArgCountErr { expected_in: vec![4], actual: msg.args.len(), addr: msg.addr}));
|
||||||
}
|
}
|
||||||
let enable: i32;
|
let enable: i32;
|
||||||
let x: f32;
|
let x: f32;
|
||||||
|
@ -1326,20 +1326,20 @@ impl MessageBehavior for VmcExtSetEye {
|
||||||
let z: f32;
|
let z: f32;
|
||||||
match msg.args[0] {
|
match msg.args[0] {
|
||||||
OscType::Int(i) => enable = i,
|
OscType::Int(i) => enable = 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::Float(f) => x = f,
|
OscType::Float(f) => x = f,
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[1], addr: msg.addr, arg_count: 1}))
|
||||||
}
|
}
|
||||||
|
|
||||||
match msg.args[2] {
|
match msg.args[2] {
|
||||||
OscType::Float(f) => y = f,
|
OscType::Float(f) => y = f,
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[2], addr: msg.addr, arg_count: 2}))
|
||||||
}
|
}
|
||||||
match msg.args[3] {
|
match msg.args[3] {
|
||||||
OscType::Float(f) => z = f,
|
OscType::Float(f) => z = f,
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: vec![OscType::Float(0.0)], actual: msg.args[3], addr: msg.addr, arg_count: 3}))
|
||||||
}
|
}
|
||||||
return Ok(VmcExtSetEye { enable, position: Vector3::new(x, y, z)})
|
return Ok(VmcExtSetEye { enable, position: Vector3::new(x, y, z)})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user