[][src]Enum d3_components::network::NetCmd

pub enum NetCmd {
    Stop,
    BindListener(StringNetSender),
    NewConn(NetConnIdStringStringusize),
    BindConn(NetConnIdNetSender),
    CloseConn(NetConnId),
    RecvBytes(NetConnIdVec<u8>),
    SendBytes(NetConnIdVec<u8>),
    SendReady(NetConnIdusize),
}

This is where d3 meets Tcp (Udp to follow). The Network leans heavily upon Mio to provide the foundation for interacting with the network. The d3 network provides an additional abstraction to adapt it for d3 machines and encapsulate Mio.

This sequence diagram illustrates a machine, Alice asking for a listener to be installed. When there is a connection, the network is told to send control and data commands to the machine Bob.

+-------+                                             +-----+                        +-----+
| Alice |                                             | Net |                        | Bob |
+-------+                                             +-----+                        +-----+
   |                                                    |                              |
   | BindListner(addres, Alice:sender)                  |                              |
   |--------------------------------------------------->|                              |
   | -------------------------------\                   |                              |
   |-| Alice waits for a connection |                   |                              |
   | |------------------------------|                   |                              |
   |                                                    |                              |
   |    NewConn(conn_id, local, remote, write_buf_size) |                              |
   |<---------------------------------------------------|                              |
   | ----------------------------------\                |                              |
   |-| Alice is told of the connection |                |                              |
   | | and has Bob handle it           |                |                              |
   | |---------------------------------|                |                              |
   | BindConn(conn_id, Bob:sender)                      |                              |
   |--------------------------------------------------->|                              |
   |                                                    |      ----------------------\ |
   |                                                    |      | Bob waits for bytes |-|
   |                                                    |      |---------------------| |
   |                                                    |                              |
   |                                                    | RecvBytes(conn_id, bytes)    |
   |                                                    |----------------------------->|
   |                                                    |     -----------------------\ |
   |                                                    |     | Bob sends some bytes |-|
   |                                                    |     |----------------------| |
   |                                                    |                              |
   |                                                    |    SendBytes(conn_id, bytes) |
   |                                                    |<-----------------------------|
   |                                                    |    ------------------------\ |
   |                                                    |    | Bob may be told how   |-|
   |                                                    |    | much more he can send | |
   |                                                    |    |-----------------------| |
   |                                                    | SendReady(write_buf_size)    |
   |                                                    |----------------------------->|
   |                                                    |----------------------------\ |
   |                                                    || Bob Closes the connection |-|
   |                                                    ||---------------------------| |
   |                                                    |                              |
   |                                                    |               Close(conn_id) |
   |                                                    |<-----------------------------|
   |                                                    |                              |

Variants

Stop

Stop the network. Stop is used in conjuntion with starting and stopping the Server and Network.

BindListener(StringNetSender)

Binds a TCP listener to an address, notifying the sender when a connection is accepted.

NewConn(NetConnIdStringStringusize)

New connection notification (connection_id, bind_addr, connect_from, max_byte) are sent to the sender regitered via the BindListener.

BindConn(NetConnIdNetSender)

BindConn starts the flow of information (connection_id, sender) between the network and a sender.

CloseConn(NetConnId)

When sent to the network, CloseConn closes the connection, also known as a local close. When received by the BindConn listener, CloseConn is notification that the connection has been closed, also known as a remote close.

RecvBytes(NetConnIdVec<u8>)

Sent to the BindConn sender, RecvBytes provides bytes read from the connection.

SendBytes(NetConnIdVec<u8>)

Sent to the network, SendBytes provides bytes to be written to the network.

SendReady(NetConnIdusize)

Sent to the BindConn sender, it provides an update to the number of bytes availbe for writing to the network. A use case for this would be providing feedback for throttling data being generated for a connection.

Trait Implementations

impl Debug for NetCmd[src]

impl MachineImpl for NetCmd[src]

type Adapter = MachineBuilderNetCmd

type SenderAdapter = SenderAdapterNetCmd

type InstructionSet = NetCmd

Auto Trait Implementations

impl RefUnwindSafe for NetCmd

impl Send for NetCmd

impl Sync for NetCmd

impl Unpin for NetCmd

impl UnwindSafe for NetCmd

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,