Struct fbp::fbp_iidmessage::IIDMessage[][src]

pub struct IIDMessage { /* fields omitted */ }
Expand description

Provides the structure of a message that is sent between FBP nodes.

Implementations

Creates a new IIDMessage with a specific type and optional payload

An IIDMesage 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::*;

let a_msg = IIDMessage::new(MessageType::Data, Some("This is a payload".to_string()));

Retrieves a message’s msg_type

Example

Basic usage:

use fbp::fbp_iidmessage::*;

let a_msg = IIDMessage::new(MessageType::Data, Some("This is a payload".to_string()));

match a_msg.msg_type() {
	MessageType::Data => { /* Deal with a Data Message */ },
	MessageType::Config => { /* Deal with a Config Message */ },
	MessageType::Process => { /* Deal with a Process Message */ },
	_ => { /* Invalid or unknown message type */ },
};

Retrieves a messages’s subtype

Example

Basic usage:

use fbp::fbp_iidmessage::*;

pub fn deal_with_msg(a_msg: IIDMessage) {
	if a_msg.sub_msg_type() == SubMessageType::Reply {
		// ignore the message
	}
}

Retrieves a messages’s payload

Example

Basic usage:

use fbp::fbp_iidmessage::*;

pub fn process_msg(a_msg: IIDMessage) {
	let msg_payload = a_msg.payload();
	if msg_payload.is_some() {
		// do something with the payload
	}
}

Returns a mutable reference to the messages’s submesssage type so that it maybe changed.

Example

Basic usage:

use fbp::fbp_iidmessage::*;

pub fn set_msg_reply(a_msg: &mut IIDMessage) {
	*a_msg.sub_msg_type_mut() =  SubMessageType::Reply;
}

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

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.