This question is similar to this one but specific to rust. How can I readact password from a URL?. This is mainly for logging purposes.
To make it clear I am looking for similar kind of API in rust.
>>> from pip._internal.utils.misc import redact_auth_from_url
>>>
>>> redact_auth_from_url("https://user:[email protected]/path?key=value#hash")
'https://user:****@example.com/path?key=value#hash'
>>> redact_auth_from_url.__doc__
'Replace the password in a given url with ****.'
I did check the rust-url crate but I could not find an equivalent function.
You could use
set_password
in conjunction withpassword
:Or, as a function mimicking the
redact_auth_from_url
interface: