aboutsummaryrefslogtreecommitdiff
path: root/src/message/signalproxy/translation
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/message/signalproxy/translation/mod.rs93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/message/signalproxy/translation/mod.rs b/src/message/signalproxy/translation/mod.rs
index 064257c..6a21ec0 100644
--- a/src/message/signalproxy/translation/mod.rs
+++ b/src/message/signalproxy/translation/mod.rs
@@ -1,6 +1,99 @@
+/**
+Quassel has 3 main ways to represent an object over the Network:
+
+# VariantList
+The struct is serialized to a Vector of Variants. This is mostly used in the InitData messages.
+First the field name as a ByteArray (UTF-8 String), followed by the field value in it's own Type's variant.
+The order in which the fields are transmitted cannot be assumed.
+
+Example:
+```ignore
+NetworkConfig {
+ ping_timeout_enabled: true,
+ ping_interval: 0,
+}
+```
+to
+```ignore
+VariantList([
+ ByteArray(
+ "pingTimeoutEnabled",
+ ),
+ bool(
+ true,
+ ),
+ ByteArray(
+ "pingInterval",
+ ),
+ i32(
+ 30,
+ ),
+])
+```
+
+
+# VariantMap
+The struct is represented as a `VariantMap`. The keys and values of
+the struct are serialized to a corresponding `HashMap<String, Variant>`.
+
+Example:
+```ignore
+NetworkConfig {
+ ping_timeout_enabled: false,
+ ping_interval: 0,
+}
+```
+to
+```ignore
+VariantMap({
+ "pingTimeoutEnabled": bool(false)
+ "pingInterval": i32(0)
+})
+```
+
+## Structure of Arrays
+
+For Objects that are transmitted as multiple at once the VariantMap
+representation is augemented and instead of transmitting multiple `VariantMaps`,
+each field is a `VariantList` of Items.
+
+Example:
+```ignore
+vec![
+ NetworkConfig {
+ ping_timeout_enabled: false,
+ ping_interval: 0,
+ },
+ NetworkConfig {
+ ping_timeout_enabled: true,
+ ping_interval: 1,
+ },
+]
+```
+to
+```ignore
+VariantMap({
+ "pingTimeoutEnabled": VariantList([
+ bool(false),
+ bool(true),
+ ]),
+ "pingInterval": VariantList([
+ i32(0),
+ i32(1),
+ ])
+})
+```
+**/
+use crate::primitive::VariantMap;
+
pub trait Network {
type Item;
fn to_network(&self) -> Self::Item;
fn from_network(input: &mut Self::Item) -> Self;
}
+
+pub trait NetworkMap {
+ fn to_variantmap(&self) -> VariantMap;
+ fn from_variantmap(input: &mut VariantMap) -> Self;
+}
/a>Max Audron-105/+55 this is due to the url shorterner dying randomly and also just generally bad idea to call external services during unit tests. 2021-10-20bump version to 1.6.2Max Audron-3/+2 2021-10-20prepare for release on crates.ioMax Audron-39/+65 2021-10-20add async docs to macro crate and bump versionMax Audron-9/+10 2021-10-20change hook errors to be logged as warningsMax Audron-3/+3 they in nearly all cases aren't critical enough to warrant an actual error messages 2021-10-20fix configuration not loading correctly on release buildsMax Audron-8/+23 2021-10-19replace sedregex crate8-rework-sedMax Audron-20/+358 This replaces the sedregex crate with our own implementation for multiple reasons: 1. We required to access the parsed regex, this required a patch to the sedregex crate which did not get merged due to an inactive dev, blocking us from publishing on crates.Io 2. We wanted to highlight the changes done in bold 3. We want to add execution of multiple chained sed commands in the future which would require more modification 2021-10-19add formatting trait for irc codesMax Audron-0/+129 add an impl off the formatting trait on String to format Strings with the typical irc formatting codes for bold, italic etc 2021-10-17fix links in readmeMax Audron-2/+2