Skip to main content

try_clipboard_copy_secret

Function try_clipboard_copy_secret 

pub fn try_clipboard_copy_secret(
    text: &str,
    clear_after: Duration,
) -> ClipboardCopy
Expand description

Copy a secret — a password, a one-time code, a recovery key, an enrolment token — so it pastes anywhere as plain text while clipboard histories and device sync are told not to keep it (ClipboardBackend::set_secret_text).

After clear_after the clipboard is cleared if it still holds this secret; something copied since is left alone. A browser page has no thread to wait on, so there the clipboard is not cleared.

Fails when no shared clipboard takes the secret: it is never kept in a buffer private to this process. Like try_clipboard_copy, it never waits, and its outcome may settle later.