custom message parsing errors #1
18
src/lib.rs
18
src/lib.rs
|
@ -1134,9 +1134,9 @@ impl MessageBehavior for VmcExtSettingWin {
|
||||||
args,
|
args,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
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 mut result = Self {
|
let mut result = Self {
|
||||||
is_top_most: false,
|
is_top_most: false,
|
||||||
|
@ -1149,28 +1149,28 @@ impl MessageBehavior for VmcExtSettingWin {
|
||||||
if i == 1 {
|
if i == 1 {
|
||||||
result.is_top_most = true;
|
result.is_top_most = true;
|
||||||
} else if i != 0 {
|
} else if i != 0 {
|
||||||
return Err(String::from("arg value invalid"));
|
return Err(FromMessageErr::IntRange(IntRangeErr { expected_lower: 0, expected_upper: 1, actual: i, addr: msg.addr, arg_count: 0}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::Int(0), actual: msg.args[0], addr: msg.addr, arg_count: 0})),
|
||||||
}
|
}
|
||||||
match msg.args[1] {
|
match msg.args[1] {
|
||||||
OscType::Int(i) => {
|
OscType::Int(i) => {
|
||||||
if i == 1 {
|
if i == 1 {
|
||||||
result.is_transparent = true;
|
result.is_transparent = true;
|
||||||
} else if i != 0 {
|
} else if i != 0 {
|
||||||
return Err(String::from("arg value invalid"));
|
return Err(FromMessageErr::IntRange(IntRangeErr { expected_lower: 0, expected_upper: 1, actual: i, addr: msg.addr, arg_count: 1}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::Int(0), actual: msg.args[1], addr: msg.addr, arg_count: 1})),
|
||||||
}
|
}
|
||||||
match msg.args[2] {
|
match msg.args[2] {
|
||||||
OscType::Int(i) => result.window_click_through = i,
|
OscType::Int(i) => result.window_click_through = i,
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::Int(0), actual: msg.args[2], addr: msg.addr, arg_count: 2})),
|
||||||
}
|
}
|
||||||
match msg.args[2] {
|
match msg.args[3] {
|
||||||
OscType::Int(i) => result.hide_border = i,
|
OscType::Int(i) => result.hide_border = i,
|
||||||
_ => return Err(String::from("arg type invalid")),
|
_ => return Err(FromMessageErr::ArgType(ArgTypeErr { expected: OscType::Int(0), actual: msg.args[3], addr: msg.addr, arg_count: 3})),
|
||||||
}
|
}
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user