pub struct UrlPolicy { /* private fields */ }Expand description
Decides which URLs a UrlOpener hands to the platform.
The default, UrlPolicy::allows_by_default, lets through only absolute
http, https, and mailto URLs without control characters, so links in
untrusted content, such as Markdown from the network or a model, cannot
launch local files, scripts, or arbitrary protocol handlers. An app that
needs more registers its own check with UrlPolicy::new, or turns the
check off with UrlPolicy::allow_all.
Implementations§
Source§impl UrlPolicy
impl UrlPolicy
Sourcepub fn new(allows: impl Fn(&str) -> bool + 'static) -> UrlPolicy
pub fn new(allows: impl Fn(&str) -> bool + 'static) -> UrlPolicy
A policy that lets through the URLs allows returns true for. Call
Self::allows_by_default from it to extend the default instead of
replacing it:
let policy = UrlPolicy::new(|url| {
url.starts_with("myapp:") || UrlPolicy::allows_by_default(url)
});Sourcepub fn allow_all() -> UrlPolicy
pub fn allow_all() -> UrlPolicy
A policy that lets every URL through. Use it only when the app trusts every URL it opens.
Sourcepub fn allows_by_default(url: &str) -> bool
pub fn allows_by_default(url: &str) -> bool
The default check: whether url is an absolute http, https, or
mailto URL without control characters. Relative URLs never pass.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UrlPolicy
impl !Send for UrlPolicy
impl !Sync for UrlPolicy
impl !UnwindSafe for UrlPolicy
impl Forget for UrlPolicy
impl Freeze for UrlPolicy
impl Move for UrlPolicy
impl Unpin for UrlPolicy
impl UnsafeUnpin for UrlPolicy
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.