pub struct Send { /* private fields */ }Implementations§
Source§impl Send
impl Send
Sourcepub fn new(
mode: SendMode,
from: SocketAddr,
to: SocketAddr,
buffer: Vec<u8>,
) -> Self
pub fn new( mode: SendMode, from: SocketAddr, to: SocketAddr, buffer: Vec<u8>, ) -> Self
Creates a new Send action.
Examples found in repository?
examples/bind_and_connect.rs (lines 57-62)
48fn create_node_1() -> Node {
49 let mut node = Node::new("test-node-1");
50 let bind_action = Bind::new("192.168.1.10:3000".parse().unwrap());
51 let sleep_action = Sleep::new(1000);
52 let connection_action = Connect::new(
53 "192.168.1.10:0".parse().unwrap(),
54 "192.168.1.11:4000".parse().unwrap(),
55 1000,
56 );
57 let send_unicast_action = Send::new(
58 SendMode::Unicast,
59 "192.168.1.10:3000".parse().unwrap(),
60 "192.168.1.11:4000".parse().unwrap(),
61 vec![1, 2, 3, 4],
62 );
63
64 let send_broadcast_action = Send::new(
65 SendMode::Broadcast,
66 "192.168.1.10:0".parse().unwrap(),
67 "192.168.1.255:49999".parse().unwrap(),
68 vec![1, 2, 3, 4],
69 );
70
71 let wait_connection_action = Wait::new(WaitEvent::Connection(ConnectPredicate::new(
72 "192.168.1.11:0".parse().unwrap(),
73 "192.168.1.10:3000".parse().unwrap(),
74 )));
75
76 let wait_message_action = Wait::new(WaitEvent::Messages(ReceivePredicate::new(vec![
77 MessagesPredicate {
78 from: "192.168.1.11:0".parse().unwrap(),
79 to: "192.168.1.10:3000".parse().unwrap(),
80 buffer: vec![1, 1],
81 },
82 ])));
83
84 node.add_action(bind_action);
85 node.add_action(sleep_action.clone());
86 node.add_action(send_broadcast_action);
87 node.add_action(wait_connection_action);
88 node.add_action(wait_message_action);
89 node.add_action(connection_action);
90 node.add_action(send_unicast_action);
91 node.add_action(sleep_action);
92
93 node
94}
95
96fn create_node_2() -> Node {
97 let mut node = Node::new("test-node-2");
98 let bind_action = Bind::new("192.168.1.11:4000".parse().unwrap());
99 let sleep_action = Sleep::new(5000);
100 let connection_action = Connect::new(
101 "192.168.1.11:0".parse().unwrap(),
102 "192.168.1.10:3000".parse().unwrap(),
103 1000,
104 );
105
106 let send_unicast_action = Send::new(
107 SendMode::Unicast,
108 "192.168.1.11:4000".parse().unwrap(),
109 "192.168.1.10:3000".parse().unwrap(),
110 vec![1, 1],
111 );
112
113 node.add_action(bind_action);
114 node.add_action(sleep_action.clone());
115 node.add_action(connection_action);
116 node.add_action(sleep_action);
117 node.add_action(send_unicast_action);
118
119 node
120}pub fn from(&self) -> &SocketAddr
pub fn to(&self) -> &SocketAddr
pub fn buffer(&self) -> &[u8] ⓘ
Trait Implementations§
impl StructuralPartialEq for Send
Auto Trait Implementations§
impl Freeze for Send
impl RefUnwindSafe for Send
impl Send for Send
impl Sync for Send
impl Unpin for Send
impl UnsafeUnpin for Send
impl UnwindSafe for Send
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more