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
	},
};

Retrieves a Config messages’s data

Example

Basic usage:

use fbp::fbp_iidmessage::*;

pub fn process_config_msg(a_msg: ConfigMessage) {
	let data = a_msg.data();
	if data.is_some() {
		// do something with the data
	}
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

This will deserialize a JSON string that is a serialized Rust struct back into the original struct Read more

This will take a struct and serialize that struct into a JSON string that will then become the payload of an IIDMesssage Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.