pub const RedirectBehavior = enum(u16) pub fn init(n: u16) RedirectBehaviorpub fn subtractOne(rb: *RedirectBehavior) voidpub fn remaining(rb: RedirectBehavior) u16857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882 pub const RedirectBehavior = enum(u16) {
/// The next redirect will cause an error.
not_allowed = 0,
/// Redirects are passed to the client to analyze the redirect response
/// directly.
unhandled = std.math.maxInt(u16),
_,
pub fn init(n: u16) RedirectBehavior {
assert(n != std.math.maxInt(u16));
return @fromBackingInt(@intCast(n));
}
pub fn subtractOne(rb: *RedirectBehavior) void {
switch (rb.*) {
.not_allowed => unreachable,
.unhandled => unreachable,
_ => rb.* = @fromBackingInt(@intCast(@backingInt(rb.*) - 1)),
}
}
pub fn remaining(rb: RedirectBehavior) u16 {
assert(rb != .unhandled);
return @backingInt(rb);
}
}
Any value other than
not_allowedorunhandledmeans that integer represents how many remaining redirects are allowed.