From b846fcf55b0477a8642f5f985b9fe4ee4ea2c801 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Thu, 22 Jul 2021 18:11:44 +0700 Subject: [PATCH] Fix `MessageReader` documentation --- src/link/mod.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/link/mod.rs b/src/link/mod.rs index e54c9cd..eeba2fe 100644 --- a/src/link/mod.rs +++ b/src/link/mod.rs @@ -45,13 +45,16 @@ pub struct MessageReader { received_bytes: u64, } -/// For converting byte stream expected to be generated by Acedia mod from the game server into -/// actual messages. Expected format is a sequence of either: -/// [HEAD_UE_RECEIVED: 1 byte] [amount of bytes received by game server since last update: 4 bytes] -/// [HEAD_UE_MESSAGE: 1 byte] [length of the message: 4 bytes] [utf8-encoded string: ??? bytes] -/// On any invalid input enters a failure state (can be checked by `is_broken()`) and +/// For converting byte stream that is expected from the ue-server into actual messages. +/// Expected format is a sequence of either: +/// 1. [HEAD_UE_RECEIVED: marker byte | 1 byte] +/// [AMOUNT: amount of bytes received by ue-server since last update | 4 bytes: u32 BE] +/// 2. [HEAD_UE_MESSAGE: marker byte | 1 byte] +/// [LENGTH: length of the JSON message in utf8 encoding | 4 bytes: u32 BE] +/// [PAYLOAD: utf8-encoded string | `LENGTH` bytes] +/// On any invalid input enters into a failure state (can be checked by `is_broken()`) and /// never recovers from it. -/// Use either `push_byte()` or `push()` to input byte stream from game server and `pop()` to +/// Use either `push_byte()` or `push()` to input byte stream from ue-server and `pop()` to /// retrieve resulting messages. impl MessageReader { pub fn new() -> MessageReader {