Ip2long function in rust

Hello,

I'm creating a program to know some information of ip and I need to use the function ip2long available in php and javascript but not in rust. I don't know how to reproduce this function in rust. I've tried to make this function in rust but I'm not very good.

PHP function : PHP: ip2long - Manual
Javascript function : https://raw.githubusercontent.com/kvz/locutus/master/src/php/network/ip2long.js

From std documentation (Ipv4Addr in std::net - Rust):

playground

?

1 Like

I've see Ipv4Addr documentation but I did not know u32::from(addr) exist. This code work very well. Thanks you !

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.