| Crates.io | nseqe |
| lib.rs | nseqe |
| version | 0.1.0 |
| created_at | 2025-05-26 17:12:22.630572+00 |
| updated_at | 2025-05-26 17:12:22.630572+00 |
| description | A Rust library for managing and processing sequences of events. |
| homepage | |
| repository | https://github.com/tylp/nseqe |
| max_upload_size | |
| id | 1690069 |
| size | 59,321 |
Network Sequence Executor
NSE is a library that allow users to create a sequence of messages exchange between hosts. Messages are of TCP type and can be described with a custom protocol.
A node represents a host on the network. It is defined by:
tasks, which run in the backgroundsequence, which defines the ordered actions the node will performnode:
tasks: []
sequence:
Tasks are asynchronous, periodic actions that persist throughout the application's lifetime.
They are executed in parallel with the sequence.
Each entry in a node's sequence is called an action, defined by the required "action" key.
The fields associated with an action vary depending on its type.
Each action must specify a protocol. The supported protocols currently are tcp and udp.
The supported actions are
connect – establish a connection to a remote hostdisconnect – close a connection to a remote hostbind – create a TCP server socketsend – send a message (unicast or broadcast)wait – wait for an event to occursleep – block the sequence for a given durationThe connect action makes a socket connection to a remote host (or node).
action: connect
to:
addr: 192.168.1.5
port: 8000
timeout_ms: 5000
The disconnect action disconnect the node from a remote host if a connection between the two exists.
action: disconnect
target:
addr: 192.168.1.5
port: 8000
The bind action creates a TCP server on the given address and port.
action: bind
interface:
addr: 192.168.1.4
port: 8000
protocol: tcp
Sends a message either to specific remote hosts (unicast) or to a whole subnet (broadcast).
ℹ️ If the mode is
unicast, an active connection (seeconnect) is required.
action: send
mode: unicast
protocol: tcp
from:
addr: 192.168.0.1
to:
- addr: 192.168.0.6
port: 6900
buffer: [0x1, 0x1, 0x1]
action: send
mode: broadcast
from:
addr: 192.168.0.1
to:
subnet: 192.168.0.0/24
buffer: [0x1, 0x1, 0x1]
The sleep event waits for a given amount of time before executing the next action.
action: sleep
duration_ms: 5000
Blocks the sequence until a specified event occurs. Running tasks are not paused.
Supported events are :
sleep: pause for a durationmessages: wait for specific incoming messagesconnection: wait for a remote client to connectWaits for one or more remote clients to connect to the local server.
action: wait
event: connection
protocol: tcp
connections:
- from:
addr: 192.168.1.2
to:
addr: 192.168.1.4
port: 3000
Waits for a list of incoming messages, optionally in a defined order.
unordered: proceed when all messages are received, in any order.ordered: messages must arrive in the defined order; otherwise, the sequence is blocked until the timeout.action: wait
event: messages
timeout: 5000
messages:
order: unordered
list:
- from:
addr: 192.168.0.6
port: 6900
to:
addr: 192.168.0.1
port: 6901
protocol: udp
buffer: [0x1, 0x1, 0x1]
expect_response: false
enum Action {
Connect { to: Endpoint, timeout_ms: u64 },
Disconnect { target: Endpoint },
Bind { interface: Endpoint, protocol: Protocol },
Send { mode: SendMode, from: Address, to: Vec<Endpoint>, buffer: Vec<u8> },
Sleep { duration_ms: u64 },
Wait { event: WaitEvent },
}
enum WaitEvent {
Connection(Vec<ConnectionSpec>),
Messages { order: OrderType, list: Vec<MessageMatch>, timeout_ms: Option<u64> }
This example create a server on a local IP address and port. Once the client connects, the node sends a message to it.
node:
tasks: []
sequence:
- action: bind
interface:
addr: 192.168.1.4
port: 8000
protocol: tcp
- action: wait
event: connection
connections:
- from:
addr: 192.168.1.3
to:
addr: 192.168.1.4
port: 8000
protocol: tcp
- action: send
mode: unicast
from:
addr: 192.168.1.4
to:
- addr: 192.168.1.3
port: 9999
protocol: udp
buffer: [0x1, 0x1, 0x1]