Initial valve setup and tf2 game setup

This commit is contained in:
CosminPerRam 2022-10-15 22:20:01 +03:00
parent e2be20ee53
commit 8098136d09
10 changed files with 234 additions and 12 deletions

20
src/utils.rs Normal file
View file

@ -0,0 +1,20 @@
use std::ops::Add;
pub fn concat_u8(first: &[u8], second: &[u8]) -> Vec<u8> {
[first, second].concat()
}
pub fn find_null_in_array(arr: &[u8]) -> usize {
match arr.iter().position(|&x| x == 0) {
None => arr.len(),
Some(position) => position
}
}
pub fn complete_address(address: &str, port: u16) -> String {
String::from(address.to_owned() + ":").add(&*port.to_string())
}
pub fn combine_two_u8(high: u8, low: u8) -> u16 {
((high as u16) << 8) | low as u16
}