pub struct CopyOptions { /* private fields */ }Expand description
How Cx::copy_with copies. CopyOptions::new is a plain copy (like cx.copy, but with
a reply); CopyOptions::sensitive is the preset for a password, a recovery code or a TOTP secret.
What each platform honours:
mark_sensitive: Android hides the text in the clipboard preview (Android 13+) and asks keyboards not to keep it. iOS has no equivalent. The web can’t.expires_after: iOS removes the item itself. On Android it is best effort: the shell clears the clipboard when the time is up, but only while it still holds this copy. Android 10+ lets only the app in front read the clipboard, so after the user switches away (say, to paste the secret into another app) it clears within about 5 s of the app coming back to the front, gives up an hour after the deadline, and never clears if the process dies first. Android 13+ clears the clipboard itself after about an hour. The hidden preview is Android’s dependable protection. The web can’t expire a copy.local_only: iOS keeps the item out of Universal Clipboard. No effect on Android (an OEM or companion-app clipboard sync may still carry it) or the web.
A shell that predates clipboard_with answers ok: false. Don’t fall back to cx.copy then: that is the plain
copy this exists to avoid.
Implementations§
Source§impl CopyOptions
impl CopyOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
A plain copy: not sensitive, never expires, may sync to the user’s other devices.
Sourcepub fn sensitive() -> Self
pub fn sensitive() -> Self
Sensitive, expires after 2 minutes, kept off other devices (iOS). Every field can still be changed.
Sourcepub fn mark_sensitive(self, on: bool) -> Self
pub fn mark_sensitive(self, on: bool) -> Self
Hide the text in the clipboard preview and ask keyboards not to keep it (Android).
Sourcepub fn expires_after(self, d: Duration) -> Self
pub fn expires_after(self, d: Duration) -> Self
Remove the copy after d (at least 1 s); best effort on Android, see CopyOptions.
Sourcepub fn never_expires(self) -> Self
pub fn never_expires(self) -> Self
Leave the copy on the clipboard until something replaces it.
Sourcepub fn local_only(self, on: bool) -> Self
pub fn local_only(self, on: bool) -> Self
Keep the copy on this device (iOS: out of Universal Clipboard).