Warning
This post was published 70 days ago. The information described in this article may have changed.
I am querying NETCONF for Nokia's. The platforms may have different versions, so I did my structs like so:
pub struct Config {
pub error: Option<RpcError>,
pub xconfig: Option<XConfigRpcReply>,
pub sconfig: Option<SConfigRpcReply>,
}
impl Config {
fn new(error: Option<RpcError>,
xconfig: Option<XConfigRpcReply>,
sconfig: Option<SConfigRpcReply>,) -> Config {
return
Config {
error,
xconfig,
sconfig,
}
}
}
#[derive(Debug)]
pub struct XConfigRpcReply {
pub config: nokia_ixr_x_config::RpcReply,
}
#[derive(Debug)]
pub struct SConfigRpcReply {
pub config: nokia_ixr_s_config::RpcReply,
}
This all works quite well until I have to get the data out of these. Do I have an XConfig or SConfig? Trying to match doesn't seem to work because match takes the first arm as the expected type and the second arm becomes a mismatched type.
I am wondering how to solve this. Would a Traits with for the two Config types do it?
3 posts - 2 participants
🏷️ rust_feed