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/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/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/web.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/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/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/web.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 the URI.

Examples found in repository?
examples/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/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/web.rs (line 4)
1fn main() {
2    robius_open::Uri::new("https://github.com/project-robius")
3        .action("ACTION_VIEW")
4        .open()
5        .unwrap();
6}

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> 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.