Skip to main content

Send

Struct Send 

Source
pub struct Send { /* private fields */ }

Implementations§

Source§

impl Send

Source

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}
Source

pub fn from(&self) -> &SocketAddr

Source

pub fn to(&self) -> &SocketAddr

Source

pub fn buffer(&self) -> &[u8]

Trait Implementations§

Source§

impl Action for Send

Source§

fn perform<'life0, 'async_trait>( &'life0 self, ctx: Arc<Mutex<NodeContext>>, ) -> Pin<Box<dyn Future<Output = Result<(), ActionError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sends data from from to to using the specified mode.

Source§

fn name(&self) -> String

Source§

impl Clone for Send

Source§

fn clone(&self) -> Send

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Send

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Send

Source§

fn eq(&self, other: &Send) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more