diff --git a/crates/lb/src/net.rs b/crates/lb/src/net.rs index 0dc07a2..3c36cf2 100644 --- a/crates/lb/src/net.rs +++ b/crates/lb/src/net.rs @@ -82,18 +82,18 @@ impl lb_netlib { /// If `s` is an [`lb_ipaddr`], a copy of that value is returned. If `s` is an /// [`lb_socketaddr`], the IP address part of the socket address is returned. Otherwise, parses /// `s` as an IP address string. Both IPv4 or IPv6 addresses are supported. - pub extern "Lua" fn ipaddr(&self, s: any) -> Result { - if __istype(__ct.lb_ipaddr, s) { - __new(__ct.lb_ipaddr, s) // copy constructor - } else if __istype(__ct.lb_socketaddr, s) { + pub extern "Lua" fn ipaddr(&self, addr: any) -> Result { + if __istype(__ct.lb_ipaddr, addr) { + __new(__ct.lb_ipaddr, addr) // copy constructor + } else if __istype(__ct.lb_socketaddr, addr) { s.ip() } else { - self.__parse_ipaddr(s) + self.__parse_ipaddr(addr) } } - extern "Lua-C" fn __parse_ipaddr(&self, s: &str) -> Result { - Ok(s.parse()?) + extern "Lua-C" fn __parse_ipaddr(&self, addr: &str) -> Result { + Ok(addr.parse()?) } /// Creates an [`lb_socketaddr`] from the given input. @@ -105,16 +105,16 @@ impl lb_netlib { /// socket address string. Both IPv4 and IPv6 addresses are supported. /// /// If `port` is not specified, `0` is used as the default. - pub extern "Lua" fn socketaddr(&self, s: any, port: any) -> Result { + pub extern "Lua" fn socketaddr(&self, addr: any, port: any) -> Result { if port != () { - self.__new_skaddr(self.ipaddr(s), port) + self.__new_skaddr(self.ipaddr(addr), port) } else { - if __istype(__ct.lb_socketaddr, s) { - __new(__ct.lb_socketaddr, s) // copy constructor - } else if __istype(__ct.lb_ipaddr, s) { - self.__new_skaddr(s, 0) // default port 0 + if __istype(__ct.lb_socketaddr, addr) { + __new(__ct.lb_socketaddr, addr) // copy constructor + } else if __istype(__ct.lb_ipaddr, addr) { + self.__new_skaddr(addr, 0) // default port 0 } else { - self.__parse_skaddr(s) + self.__parse_skaddr(addr) } } } @@ -123,8 +123,8 @@ impl lb_netlib { SocketAddr::new(ip.0, port).into() } - extern "Lua-C" fn __parse_skaddr(&self, s: &str) -> Result { - Ok(s.parse()?) + extern "Lua-C" fn __parse_skaddr(&self, addr: &str) -> Result { + Ok(addr.parse()?) } /// Creates a new TCP socket configured for IPv4. @@ -309,13 +309,13 @@ impl lb_socketaddr { /// Sets the IP part of this address. /// /// This function accepts the same arguments as [`ipaddr`](lb_netlib::ipaddr). - pub extern "Lua" fn set_ip(&mut self, s: any) -> &mut Self { - if __istype(__ct.lb_ipaddr, s) { - self.__set_ip(s); - } else if __istype(__ct.lb_socketaddr, s) { - self.__set_ip(s.ip()); + pub extern "Lua" fn set_ip(&mut self, addr: any) -> &mut Self { + if __istype(__ct.lb_ipaddr, addr) { + self.__set_ip(addr); + } else if __istype(__ct.lb_socketaddr, addr) { + self.__set_ip(addr.ip()); } else { - self.__set_ip_parse(s); + self.__set_ip_parse(addr); } self } @@ -324,8 +324,8 @@ impl lb_socketaddr { self.0.set_ip(ip.0); } - extern "Lua-C" fn __set_ip_parse(&mut self, s: &str) -> Result<()> { - Ok(self.0.set_ip(s.parse()?)) + extern "Lua-C" fn __set_ip_parse(&mut self, addr: &str) -> Result<()> { + Ok(self.0.set_ip(addr.parse()?)) } /// Returns the port part of this address.