plat/share.rs#
Source: lib/plat/share.rs
share -- the system's share sheet: hand a text, a link or files to another app (mail, messages,
AirDrop, Nearby Share, a chat ...)
share(&Share) -> i32 SHARE_PENDING: the sheet is open, its answer comes through
share_poll (and wakes the UI); SHARE_NONE: not here -- no sheet on
this system (Linux), no window, nothing to share, a file the app
may not read or that is not there, one sheet open already
share_poll() -> Option<i32> None while it is open (or none was), then once: SHARE_DONE (a
target took the items), SHARE_CANCELLED (closed without one) or
SHARE_FAILED (the target or the system refused)
share_open() -> bool a sheet is open (its answer not taken yet)
CAP_SHARE capabilities(): this system has a share sheet
Share { title, text, url, files, anchor }: `title` the subject (a mail's subject line, Windows'
title of the data; may be empty), `text` plain text, `url` a link (http, https, mailto ...),
`files` paths of the file system or names with a scheme (data://, docs:// ...; the browser: its
virtual files) -- at least one of text, url, files. Windows, macOS and iOS get the path behind a
scheme (vfs::os_path); a file without one there (mem://) is SHARE_NONE. `anchor` [x, y, w, h] in the window's pixels: what the sheet points at where it is a
popover (macOS, an iPad); empty: the window's middle (macOS, iPad) / its usual place.
What "done" means differs (it says nothing about delivery): iOS and macOS a service was chosen
and took the items; Windows the target app took them (TargetApplicationChosen), before Windows 10
2004 the sheet has them (no word of a cancel there); the browser navigator.share resolved; Android a
target was chosen (the chooser's callback, API 22+). A sheet that cannot be shown (macOS: the
window not on screen; iOS: a controller in a transition or whose view is not in the window) is
SHARE_NONE.
Windows (win_share.rs): DataTransferManager of the active window through
IDataTransferManagerInterop (Windows 10), the data package filled in DataRequested (text, a web
link, storage items of the files). macOS (apple_mac_share.rs): NSSharingServicePicker at the
anchor in the key window. iOS (apple_ios_share.rs): UIActivityViewController over the scene's
window, on an iPad a popover at the anchor; it offers only what takes every item ("Save to
Files" only when all of them are files, a text or a link leaves it out). Browser and Android (web_share.rs): the host --
navigator.share (files as File objects; the browser asks for the user's gesture: call it while
handling input) / Intent.ACTION_SEND(_MULTIPLE) in a chooser (files through the host's provider,
readable by the target only). Linux: none.
/// the sheet is open; the answer comes through share_poll
SHARE_PENDING: i32 = 2
/// a target took the items
SHARE_DONE: i32 = 1
/// closed without a target
SHARE_CANCELLED: i32 = 0
/// not here: no sheet, no window, nothing to share, a file not readable, one open already
SHARE_NONE: i32 = -1
/// the target or the system refused
SHARE_FAILED: i32 = -2
impl Share