chalkydri/utils.rs
1//!
2//! Small utility functions
3//!
4
5/// Generate the team IP
6///
7/// Let's say you're on team number 12345 (just like all of my passwords).
8/// Here's how you'd do that:
9///
10/// ```text
11/// 1 2 3 4 5
12/// |___|___| |___|
13/// \ /
14/// 10.123.45.2
15/// ```
16///
17/// Reference:
18/// <https://docs.wpilib.org/en/stable/docs/networking/networking-introduction/ip-configurations.html#te-am-ip-notation>
19pub fn gen_team_ip(team_number: u16) -> Option<[u8; 4]> {
20 if team_number > 25_599 {
21 None
22 } else {
23 Some([10, (team_number / 100) as u8, (team_number % 100) as u8, 2])
24 }
25}