pub struct Uri<'a, 'b> { /* private fields */ }Expand description
A uniform resource identifier.
Implementations§
Source§impl<'a, 'b> Uri<'a, 'b>
impl<'a, 'b> Uri<'a, 'b>
Sourcepub fn new(s: &'a str) -> Self
pub fn new(s: &'a str) -> Self
Constructs a new URI.
Examples found in repository?
More examples
Sourcepub fn action(self, action: &'b str) -> Self
pub fn action(self, action: &'b str) -> Self
Sets the action to perform with this URI.
This only has an effect on Android, and corresponds to an action
activity. By default, it is set to "ACTION_VIEW".
§Examples
Uri::new("tel:+61 123 456 789")
.action("ACTION_DIAL")
.open()
.expect("failed to open telephone URI");Examples found in repository?
More examples
Sourcepub fn open(self) -> Result<()>
pub fn open(self) -> Result<()>
Opens this URI.
This must be called on the main UI thread, or it will return Error::NotMainThread.
Note that the returned Result does not necessarily indicate whether
the URI was successfully opened by the system.
For that purpose, you should use Self::open_with_completion().
Examples found in repository?
More examples
Sourcepub fn open_with_completion<F>(self, on_completion: F) -> Result<()>
pub fn open_with_completion<F>(self, on_completion: F) -> Result<()>
Opens this URI, with a callback for determining if the URI was successfully opened.
This must be called on the main UI thread, or it will return Error::NotMainThread.
Note that the returned Result does not necessarily indicate whether
the URI was successfully opened by the system.
For that purpose, the given on_completion callback will be called
with a boolean indicating whether the URI was successfully opened.
Note that the callback may be not be called at all,
but should typically be called upon success.
Thus, the URI was not successfully opened if this function returns an error,
OR if the on_completion callback is invoked with false.