FastLED 3.10.6
Loading...
Searching...
No Matches

◆ tryParsePort()

fl::optional< u16 > fl::net::tryParsePort ( i64 value)
inline

Convert an untrusted integer to a port number.

Returns
the port when value lies in [1, 65535], otherwise nullopt. Callers must surface the empty case as an error rather than substituting a default, since a wrong port is indistinguishable from a working one until the connection fails.

Definition at line 35 of file port.h.

35 {
37 return fl::nullopt;
38 }
39 return fl::optional<u16>(static_cast<u16>(value));
40}
constexpr i64 kMaxPort
Highest port representable in the 16-bit wire field.
Definition port.h:27
constexpr int type_rank< T >::value
Optional< T > optional
Definition optional.h:16
constexpr nullopt_t nullopt
Definition optional.h:13

References kMaxPort, fl::nullopt, and fl::type_rank< T >::value.