// A resource's method set is shared by the dispatcher and the Allow header. pub fn sw_flag(method: str) -> i64 { if method == "GET" { return 1; } if method == "HEAD" { return 2; } if method == "POST" { return 4; } if method == "PUT" { return 8; } if method == "PATCH" { return 16; } if method == "DELETE" { return 32; } if method == "OPTIONS" { return 64; } 0 } pub fn sw_accepts(mask: i64, method: str) -> bool { let bit = sw_flag(method); if mask < 0 || mask > 127 || bit == 0 { return false; } (mask / bit) % 2 == 1 } pub fn sw_status(found: bool, mask: i64, method: str) -> i64 { if !found { return 404; } if sw_accepts(mask, method) { return 200; } 405 } pub fn sw_enable(mask: i64, method: str) -> i64 { if sw_accepts(mask, method) { return mask; } mask + sw_flag(method) }