mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
Better packet structure (#3)
* [packet_structure] Initial implementation * [packet_structure] Fixed on tf2 * [packet_structure] Fixed info request
This commit is contained in:
parent
4e9458f102
commit
e621a9aedd
4 changed files with 148 additions and 74 deletions
15
src/utils.rs
15
src/utils.rs
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue