-
Notifications
You must be signed in to change notification settings - Fork 60
Event System [legacy]
Matteo Ferretti edited this page Apr 10, 2024
·
1 revision
This document describes the Event System used in Rusk.
enum Target {
Contract(String), // 0x01
Host(String). // 0x02
Debugger(String) // 0x03
}
struct Event<T> {
data: T,
target: Target,
topic: &'static str.
}
Field | Type | Description |
---|---|---|
target's type | u8 |
The target's type |
target's name length | u32 |
little endian |
target's name | [u8] |
bytes represent the name of the target in utf-8 |
event's topic length | u32 |
little endian |
event's topic | [u8] |
bytes represent the topic of the target in utf-8 |
data | [u8] |
bytes represent the data of this event |
A message is sent from a consumer (e.g. wallets) to Rusk
or from Rusk
to a consumer.
It contains the Event
to dispatch plus Headers
HTTP-like with additional information.
struct Message {
headers: HashMap<String, String>,
event: Event
}
Field | Type | Description |
---|---|---|
headers' length | u32 |
The length of the headers |
headers | [u8] |
bytes represent the headers of the request in JSON format |
event | [u8] |
See event's serialization |
The headers are key / value struct, { String : String }
.
- The
key
is case-insensitive - The prefix
Rusk-
for the header name is reserved - Any header starting with the prefix
X-
will be included back as-is from a request to a response. - Any header not recognized by Rusk without the prefix
X-
will be ignored from a request and not included in the response.
Field | Description |
---|---|
Content-Type | Content-Type |
Content-Length | The length of the message body in octets (8-bit bytes). |
Accept | Media type(s) that is/are acceptable for a response message |
Rusk-Version | The required version for the rusk node to connect with, expressed in semver |
Status | Status code and optional text expressed as HTTP status code, e.g. "200; Good news everyone!"
|
{
"Content-Type" : "application/json",
"Rusk-Version" : "0.10.2",
"X-Request-Id" : "12be34ef"
}