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
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 IIDMessage
impl Send for IIDMessage
impl Sync for IIDMessage
impl Unpin for IIDMessage
impl UnwindSafe for IIDMessage
Blanket Implementations
Mutably borrows from an owned value. Read more