spacegate_kernel/utils/
schema_port.rs1macro_rules! schema_port {
2 ($($schema: literal => $port: literal)*) => {
3 #[allow(unreachable_patterns)]
4 pub fn schema_to_port(schema: &str) -> Option<u16> {
5 match schema {
6 $(
7 $schema => Some($port),
8 _ => None,
9 )*
10 }
11 }
12 #[allow(unreachable_patterns)]
13 pub fn port_to_schema(port: u16) -> Option<&'static str> {
14 match port {
15 $(
16 $port => Some($schema),
17 _ => None,
18 )*
19 }
20 }
21 };
22}
23
24schema_port! {
25 "http" => 80
26 "ws" => 80
27 "https" => 443
28 "wss" => 443
29 "grpc" => 50051
30}