mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-18 09:35:50 +00:00
Initial valve setup and tf2 game setup
This commit is contained in:
parent
e2be20ee53
commit
8098136d09
10 changed files with 234 additions and 12 deletions
20
src/utils.rs
Normal file
20
src/utils.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue