Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
This commit is contained in:
Klim Tsoutsman 2024-04-15 21:12:04 +10:00
parent 2f6f326134
commit b1a3af91b5
No known key found for this signature in database
GPG Key ID: 4A01583A28FD626F
1 changed files with 23 additions and 0 deletions

View File

@ -1,22 +1,45 @@
//! A crate for opening files.
//!
//! ```
//! # use robius_open::Uri;
//! Uri::new("tel:+61 123 456 789").open();
//! ```
mod sys;
/// A uniform resource identifier.
pub struct Uri<'a, 'b> {
inner: sys::Uri<'a, 'b>,
}
impl<'a, 'b> Uri<'a, 'b> {
/// Constructs a new URI.
pub fn new(s: &'a str) -> Self {
Self {
inner: sys::Uri::new(s),
}
}
/// Sets the action to perform with this URI.
///
/// This only has an effect on Android, and corresponds to an [action
/// activity][aa]. By default, it is set to `"ACTION_VIEW"`.
///
/// # Examples
///
/// ```
/// # use robius_open::Uri;
/// Uri::new("tel:+61 123 456 789").action("ACTION_DIAL").open();
/// ```
///
/// [aa]: https://developer.android.com/reference/android/content/Intent#standard-activity-actions
pub fn action(self, action: &'b str) -> Self {
Self {
inner: self.inner.action(action),
}
}
/// Opens the URI.
pub fn open(self) {
self.inner.open();
}