Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Another variation of enums and struct problems
I have four different types that represent NETCONF with quick_xml that reside in a module as .rs modules. Staying the NETCONF config they look like this.
nokia_ixr_x_config::RpcReply
nokia_ixr_s_config::RpcReply
In a separate netconf module, that does get and get_config I represent those with an enum
pub enum WhichRpcReply {
RpcError{ error: rpc_error::RpcReply },
XConfigReply{ config: nokia_ixr_x_config::RpcReply},
SConfigReply{ config: nokia_ixr_s_config::RpcReply},
}
Below, I represent the configurations with another enum.
#[derive(Debug, Clone)]
pub enum Config {
//Error(WhichRpcReply ),
XConfig( WhichRpcReply),
SConfig( WhichRpcReply ),
}
Here is an example of how the get_config creates instances.
if self.equipment_type.as_str() == "ixr-s" {
match de::from_str::<nokia_ixr_s_config::RpcReply>(&filtered_config) {
Ok(res) => return Some(Config::SConfig(WhichRpcReply::SConfigReply{config: res})),
Err(err) => {
let msg = err.to_string();
error!(msg, "Problem deserializing an ixr_s config: {:?}", msg);
}
}
}
And in my tests...
let result = nc.get_config("running", None);
if result.is_some() {
let c = result.unwrap();
let l = c.rpc_reply();
if l.is_some() {
let m = l.unwrap();
println!("{:?}", m);
}
};
In the debugger, it looks like I expect.
But I do not get anything I can access with a "." operator.
9 posts - 5 participants
🏷️ rust_feed