pub struct SafeUrl(/* private fields */);Expand description
A URL that has passed scheme + IP-blocklist validation.
Construction via SafeUrl::parse is the only way to satisfy this type;
call sites that hold a SafeUrl proved they validated it.
Implementations§
Source§impl SafeUrl
impl SafeUrl
Sourcepub async fn parse(s: &str, policy: IpPolicy) -> Result<Self, Error>
pub async fn parse(s: &str, policy: IpPolicy) -> Result<Self, Error>
Parse s, require an http:// or https:// scheme, and reject if the
host is a literal blocked IP, or if any IP that the host name resolves
to is in the blocked set under policy.
DNS resolution uses tokio::net::lookup_host with the URL’s port (or
the scheme’s default port). All resolved addresses are checked; if any
resolved address is private, the URL is rejected.
Under IpPolicy::AllowPrivate, no IP check is performed (scheme check
still applies).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SafeUrl
impl RefUnwindSafe for SafeUrl
impl Send for SafeUrl
impl Sync for SafeUrl
impl Unpin for SafeUrl
impl UnsafeUnpin for SafeUrl
impl UnwindSafe for SafeUrl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more