Better packet structure (#3)

* [packet_structure] Initial implementation

* [packet_structure] Fixed on tf2

* [packet_structure] Fixed info request
This commit is contained in:
CosminPerRam 2022-10-22 01:22:09 +03:00 committed by GitHub
parent 4e9458f102
commit e621a9aedd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 148 additions and 74 deletions

View file

@ -1,10 +1,6 @@
use std::ops::Add;
use crate::{GDResult, GDError};
pub fn concat_u8_arrays(first: &[u8], second: &[u8]) -> Vec<u8> {
[first, second].concat()
}
pub fn complete_address(address: &str, port: u16) -> String {
String::from(address.to_owned() + ":").add(&*port.to_string())
}
@ -75,17 +71,6 @@ pub mod buffer {
mod tests {
use super::*;
#[test]
fn concat_u8_arrays_test() {
let a: [u8; 2] = [1, 2];
let b: [u8; 2] = [3, 4];
let combined = concat_u8_arrays(&a, &b);
assert_eq!(combined[0], a[0]);
assert_eq!(combined[1], a[1]);
assert_eq!(combined[2], b[0]);
assert_eq!(combined[3], b[1]);
}
#[test]
fn complete_address_test() {
let address = "192.168.0.1";