Expand description
Multi-platform abstractions for showing the system-native share sheet.
§Platform behavior
All types and functions in this crate are platform-independent, but native share APIs don’t expose exactly the same payload model on every OS:
- Android: sharing uses
Intent.ACTION_SENDorACTION_SEND_MULTIPLE, wrapped in the Android Sharesheet viaIntent.createChooser.- Text, URLs,
content://attachments, and filesystem path attachments are supported. - Filesystem path attachments are copied to a shareable MediaStore item on
Android 10 and newer. On older Android versions, text files can be shared
as text content, but arbitrary binary path attachments require an app
ContentProvider. - Minimum API level: 26 (Android 8.0). The bundled Java helper is loaded
via
InMemoryDexClassLoader, which requires API 26. SetminSdkto at least 26 in your app.
- Text, URLs,
- iOS: sharing uses
UIActivityViewController, with text, URLs, and filesystem path attachments. - macOS: sharing uses
NSSharingServicePicker, with text, URLs, and filesystem path attachments. - Windows: sharing uses the native WinRT Share UI through
DataTransferManagerdesktop-window interop, with text, URLs, and filesystem path attachments. - Linux: Linux doesn’t have a single standardized share sheet, so this
crate talks to the XDG desktop portal over a minimal D-Bus interface.
- A single file or URL is shared via the “Open With” app chooser.
- A mixed payload (multiple items) will open a save files dialog, and write each item to the directory chosen by the user.
- If the d-bus portal doesn’t work or isn’t available, it falls back to
xdg-open.
§Completion
- On macOS, iOS, and Windows, a successful
share()means the native share sheet was presented. - On Android and Linux, the share request is fire-and-forget, so a successful return value means that the request was dispatched, not that anything was shown.
§Examples
use robius_share::ShareSheet;
ShareSheet::new()
.set_title("Share")
.set_subject("Robius")
.add_text("Cross-platform native APIs from Rust")
.add_url("https://robius.rs/")
.share()
.expect("failed to show share sheet");Structs§
- Share
Sheet - A native share sheet builder.
- Shared
File - A file attachment in a share payload.