Struct fbp::fbp_node_context::SenderWrapper[][src]

pub struct SenderWrapper(_);
Expand description


The FBP system uses std::sync::mpsc to send IIDMessages between FBP nodes. All of the items in the FBPNodeContext are only needed at runtime and are created when the FBPNodeContext is created. This means that most of the fields in the FBPNodeContext need to be #[serde(skip)] as the FBPNodeContext does need to be Serialized for at least the name field as it is the name of the “owning” FBPNode. This is used to allow for creating a network of nodes from a JSON string. Using #[serde(skip)] requires that at least the Default trait needs to be implemented. The std::sync::mpsc structs do not implement the Default trait. One cannot implement the Default trait for a type that was not defined in the module. This issue can be solved by using the New Type Idiom

The SenderWrapper type wraps a std::sync::mpsc::Sender struct so that the Derive and Clone traits can be implemented.

Methods from Deref<Target = Sender<IIDMessage>>

Attempts to send a value on this channel, returning it back if it could not be sent.

A successful send occurs when it is determined that the other end of the channel has not hung up already. An unsuccessful send would be one where the corresponding receiver has already been deallocated. Note that a return value of Err means that the data will never be received, but a return value of Ok does not mean that the data will be received. It is possible for the corresponding receiver to hang up immediately after this function returns Ok.

This method will never block the current thread.

use std::sync::mpsc::channel;

let (tx, rx) = channel();

// This send is always successful

// This send will fail because the receiver is gone
assert_eq!(tx.send(1).unwrap_err().0, 1);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

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.