refactor(client): dedupe any pretty-debug routing
This commit is contained in:
parent
ca625bf01e
commit
ebdcebf6f7
|
|
@ -1557,72 +1557,37 @@ fn format_group_selection_detail(group: board_types::Group) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn any_to_pretty_debug(item: &prost_types::Any) -> Result<String, KiCadError> {
|
fn any_to_pretty_debug(item: &prost_types::Any) -> Result<String, KiCadError> {
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Track") {
|
macro_rules! debug_any {
|
||||||
let value = decode_any::<board_types::Track>(item, "kiapi.board.types.Track")?;
|
($(($url:literal, $ty:ty)),* $(,)?) => {
|
||||||
|
$(
|
||||||
|
if item.type_url == envelope::type_url($url) {
|
||||||
|
let value = decode_any::<$ty>(item, $url)?;
|
||||||
return Ok(format!("{:#?}", value));
|
return Ok(format!("{:#?}", value));
|
||||||
}
|
}
|
||||||
|
)*
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Arc") {
|
};
|
||||||
let value = decode_any::<board_types::Arc>(item, "kiapi.board.types.Arc")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Via") {
|
debug_any!(
|
||||||
let value = decode_any::<board_types::Via>(item, "kiapi.board.types.Via")?;
|
("kiapi.board.types.Track", board_types::Track),
|
||||||
return Ok(format!("{:#?}", value));
|
("kiapi.board.types.Arc", board_types::Arc),
|
||||||
}
|
("kiapi.board.types.Via", board_types::Via),
|
||||||
|
(
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.FootprintInstance") {
|
|
||||||
let value = decode_any::<board_types::FootprintInstance>(
|
|
||||||
item,
|
|
||||||
"kiapi.board.types.FootprintInstance",
|
"kiapi.board.types.FootprintInstance",
|
||||||
)?;
|
board_types::FootprintInstance
|
||||||
return Ok(format!("{:#?}", value));
|
),
|
||||||
}
|
("kiapi.board.types.Pad", board_types::Pad),
|
||||||
|
(
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Pad") {
|
|
||||||
let value = decode_any::<board_types::Pad>(item, "kiapi.board.types.Pad")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.BoardGraphicShape") {
|
|
||||||
let value = decode_any::<board_types::BoardGraphicShape>(
|
|
||||||
item,
|
|
||||||
"kiapi.board.types.BoardGraphicShape",
|
"kiapi.board.types.BoardGraphicShape",
|
||||||
)?;
|
board_types::BoardGraphicShape
|
||||||
return Ok(format!("{:#?}", value));
|
),
|
||||||
}
|
("kiapi.board.types.BoardText", board_types::BoardText),
|
||||||
|
("kiapi.board.types.BoardTextBox", board_types::BoardTextBox),
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.BoardText") {
|
("kiapi.board.types.Field", board_types::Field),
|
||||||
let value = decode_any::<board_types::BoardText>(item, "kiapi.board.types.BoardText")?;
|
("kiapi.board.types.Zone", board_types::Zone),
|
||||||
return Ok(format!("{:#?}", value));
|
("kiapi.board.types.Dimension", board_types::Dimension),
|
||||||
}
|
("kiapi.board.types.Group", board_types::Group),
|
||||||
|
);
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.BoardTextBox") {
|
|
||||||
let value =
|
|
||||||
decode_any::<board_types::BoardTextBox>(item, "kiapi.board.types.BoardTextBox")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Field") {
|
|
||||||
let value = decode_any::<board_types::Field>(item, "kiapi.board.types.Field")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Zone") {
|
|
||||||
let value = decode_any::<board_types::Zone>(item, "kiapi.board.types.Zone")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Dimension") {
|
|
||||||
let value = decode_any::<board_types::Dimension>(item, "kiapi.board.types.Dimension")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if item.type_url == envelope::type_url("kiapi.board.types.Group") {
|
|
||||||
let value = decode_any::<board_types::Group>(item, "kiapi.board.types.Group")?;
|
|
||||||
return Ok(format!("{:#?}", value));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"unparsed_any type_url={} raw_len={}",
|
"unparsed_any type_url={} raw_len={}",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue