pub fn require_valid_port(member: &str, port: u16) -> Result<(), Error>Expand description
Rejects a port the PortNumber or HooksPortInteger shapes would reject. Minimum 1.
§Port 0 is representable and means something else
Zero is what “let the kernel pick a port” means to a listener, so it is the value a caller
reaches for when they do not have a port yet — and issue #24 measured that
ControlPlane::with_port(0) was representable and produced allowedPorts: [{"port": 0}]
on the wire, plus a hooks.port of 0 on every image built through that plane. Neither is a
port the platform can forward to.
§There is no ceiling check here, and that is the type’s doing rather than an omission
PortNumber.max and HooksPortInteger.max are both 65535, which is u16::MAX — so a max
branch against the constant would be port > u16::MAX, a comparison that is false for every
input. Clippy’s absurd_extreme_comparisons says so, and it is right for the reason
ControlPlane::create_image gives about the absent hooks.port check: a branch no input can
reach reads as protection, appears in a coverage report as protection, and no test can make it
fire.
The ceiling is still pinned — crate::constants::MAX_PORT is in the drift gate, and
the_port_floor_is_one_and_the_ceiling_is_what_a_u16_holds asserts the equality with
u16::MAX that makes this reasoning valid. If AWS ever lowers the ceiling below 65535 the gate
goes red, that test goes red, and a real branch belongs here.