This is not possible: "Rust code that connects to a specified web server URL and retrieves the public IP of its router".
First, I assume that "a specified web server URL" means a private IP of the server in question. Because you said that it's "configured outside of DNS" which may mean that its public IP is not tied to a public domain name, so "a specified web server URL" can't mean a domain name I guess. It also doesn't make sense that "a specified web server URL" means its public IP, because otherwise this whole project of obtaining its public IP becomes pointless.
The only way to obtain the public IP of a server (which equals the public IP of its router) is to have an application server (the protocol doesn't matter) running on the server itself.
If you can't SSH into the server (which probably means no access at all to the server in question), then your task is impossible.
Now, for the application server itself (that needs to be installed on the server in question), the only way for it to know its own public IP (which, as I already said, is the same as its router public IP) is to call another server on the internet (which means via the gateway IP) that returns the IP of its caller. `ifconfig_me` (replace _ with a dot) is an example of such as service. You obviously can build your own service too.
NAT and dynamic IP are not relevant and have no effect on any component.
I did my best to make sense of your project, but please let me know if I misunderstood something.