Struct fbp::fbp_iidmessage::ConfigMessage [−][src]
pub struct ConfigMessage { /* fields omitted */ }
Expand description
Provides the structure of the payload of an IIDMessage when the IIDMessage has a type of MessageType::Config
Implementations
Creates a new ConfigMessage with a specific type and optional payload
A ConfigMessage may or may not have a payload. If no payload is required then None can be passed as the payload.
Example
Basic usage:
use fbp::fbp_iidmessage::*;
// Assuming that an FBP node has a field called log_file_path, set its value to be Log_file.txt.
// This is done with a JSON string.
let json_config_string = "{\"log_file_path\":\"Log_file.txt\"}".to_string();
let a_msg = ConfigMessage::new(ConfigMessageType::Field, Some(json_config_string));
Retrieves an ConfigMessage’s msg_type
Example
Basic usage:
use fbp::fbp_iidmessage::*;
let json_config_string = "{\"log_file_path\":\"Log_file.txt\"}".to_string();
let c_msg = ConfigMessage::new(ConfigMessageType::Field, Some(json_config_string));
let a_msg = c_msg.make_message(MessageType::Config);
match a_msg.msg_type() {
MessageType::Data => { /* Deal with a Data Message */ },
MessageType::Config => {
if a_msg.payload().is_some() {
let a_config_msg: ConfigMessage =
ConfigMessage::make_self_from_string(a_msg.payload().clone().unwrap().as_str());
match a_config_msg.msg_type() {
ConfigMessageType::Connect => {
// Deal with a Connect
},
ConfigMessageType::Disconnect => {
// Deal with a Disconnect
},
ConfigMessageType::Field => {
// Deal with setting a field in an FBP node
}
};
}
},
MessageType::Process => {
// Deal with a process message
},
_ => {
// Deal with an invalid or unknown message
},
};
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for ConfigMessage
impl Send for ConfigMessage
impl Sync for ConfigMessage
impl Unpin for ConfigMessage
impl UnwindSafe for ConfigMessage
Blanket Implementations
Mutably borrows from an owned value. Read more