Skip to main content

Uri

Struct Uri 

Source
pub struct Uri<'a, 'b> { /* private fields */ }
Expand description

A uniform resource identifier.

Implementations§

Source§

impl<'a, 'b> Uri<'a, 'b>

Source

pub fn new(s: &'a str) -> Self

Constructs a new URI.

Examples found in repository?
examples/open_tel.rs (line 2)
1fn main() {
2    robius_open::Uri::new("tel:+61 0400 000 000")
3        .action("ACTION_DIAL")
4        .open()
5        .unwrap();
6}
More examples
Hide additional examples
examples/open_mail.rs (line 2)
1fn main() {
2    robius_open::Uri::new("mailto:test@example.com")
3        .action("ACTION_MAIL")
4        .open()
5        .unwrap();
6}
examples/open_url.rs (line 2)
1fn main() {
2    robius_open::Uri::new("https://github.com/project-robius")
3        .action("ACTION_VIEW")
4        .open()
5        .unwrap();
6}
Source

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?
examples/open_tel.rs (line 3)
1fn main() {
2    robius_open::Uri::new("tel:+61 0400 000 000")
3        .action("ACTION_DIAL")
4        .open()
5        .unwrap();
6}
More examples
Hide additional examples
examples/open_mail.rs (line 3)
1fn main() {
2    robius_open::Uri::new("mailto:test@example.com")
3        .action("ACTION_MAIL")
4        .open()
5        .unwrap();
6}
examples/open_url.rs (line 3)
1fn main() {
2    robius_open::Uri::new("https://github.com/project-robius")
3        .action("ACTION_VIEW")
4        .open()
5        .unwrap();
6}
Source

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?
examples/open_tel.rs (line 4)
1fn main() {
2    robius_open::Uri::new("tel:+61 0400 000 000")
3        .action("ACTION_DIAL")
4        .open()
5        .unwrap();
6}
More examples
Hide additional examples
examples/open_mail.rs (line 4)
1fn main() {
2    robius_open::Uri::new("mailto:test@example.com")
3        .action("ACTION_MAIL")
4        .open()
5        .unwrap();
6}
examples/open_url.rs (line 4)
1fn main() {
2    robius_open::Uri::new("https://github.com/project-robius")
3        .action("ACTION_VIEW")
4        .open()
5        .unwrap();
6}
Source

pub fn open_with_completion<F>(self, on_completion: F) -> Result<()>
where F: Fn(bool) + Send + 'static,

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.

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for Uri<'a, 'b>

§

impl<'a, 'b> RefUnwindSafe for Uri<'a, 'b>

§

impl<'a, 'b> Send for Uri<'a, 'b>

§

impl<'a, 'b> Sync for Uri<'a, 'b>

§

impl<'a, 'b> Unpin for Uri<'a, 'b>

§

impl<'a, 'b> UnsafeUnpin for Uri<'a, 'b>

§

impl<'a, 'b> UnwindSafe for Uri<'a, 'b>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.