Skip to main content

Share

Struct Share 

Source
pub struct Share { /* private fields */ }
Expand description

Sharing (docs/sharing.md): Share::url(…)…present(), with the app’s own chooser actions. A link to share through the system’s share chooser, with the app’s own actions beside the system’s targets: Safari’s Add Bookmark and Find on Page. Build one with Share::url, then present it from a user action.

ⓘ
Share::url(page.url())
    .title(page.title())
    .action(share_action(res::str::add_bookmark()).symbol(Symbol::Bookmark).action(add))
    .action(share_action(res::str::find_on_page()).symbol(Symbol::Search).action(find))
    .anchor(id!(share))
    .present();

Implementations§

Source§

impl Share

Source

pub fn url(url: impl Into<String>) -> Share

Share url.

Source

pub fn title(self, title: impl Into<String>) -> Share

The link’s title: a mail’s subject, the chooser’s header where it shows one.

Source

pub fn action(self, action: ShareAction) -> Share

Offer one of the app’s own actions in the chooser, after the system’s. Where the chooser cannot carry the app’s actions (Cap::ShareActions is Unsupported), they are left out: offer the same commands in the app’s own menu as well.

Source

pub fn anchor(self, id: ElementId) -> Share

The control the chooser points at where it opens as a popover (iPad, macOS), by its element id: usually the share button itself. Without one, the chooser points at the window’s top trailing corner.

Source

pub fn present(self) -> bool

Present the chooser. Call it from a user action (the web requires one). Returns whether the chooser opened; cancelling it is not an error, and nothing reports what was shared.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Share

§

impl !Send for Share

§

impl !Sync for Share

§

impl !UnwindSafe for Share

§

impl Forget for Share

§

impl Freeze for Share

§

impl Move for Share

§

impl Unpin for Share

§

impl UnsafeUnpin for Share

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> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.