Skip to main content

CopyOptions

Struct CopyOptions 

Source
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 (some, e.g. Gboard, honour that). iOS has no system flag; it attaches the org.nspasteboard.ConcealedType convention, which only some Mac clipboard managers honour, and only if the copy reaches a Mac (local_only off). 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 there, after the user switches away (say, to paste the secret into another app), it clears within seconds of the app coming back to the front (Android 8–9 clear on time from the background), 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

Source

pub fn new() -> Self

A plain copy: not sensitive, never expires, may sync to the user’s other devices.

Source

pub fn sensitive() -> Self

Sensitive, expires after 2 minutes, kept off other devices (iOS). Every field can still be changed.

Source

pub fn mark_sensitive(self, on: bool) -> Self

Mark the copy sensitive: Android hides the preview (13+) and asks keyboards not to keep it; iOS attaches the org.nspasteboard.ConcealedType convention (see CopyOptions).

Source

pub fn expires_after(self, d: Duration) -> Self

Remove the copy after d (at least 1 s); best effort on Android, see CopyOptions.

Source

pub fn never_expires(self) -> Self

Leave the copy on the clipboard until something replaces it.

Source

pub fn local_only(self, on: bool) -> Self

Keep the copy on this device (iOS: out of Universal Clipboard).

Trait Implementations§

Source§

impl Clone for CopyOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CopyOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CopyOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for CopyOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CopyOptions

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.