alpaca-trader-rs 0.6.0

Alpaca Markets trading toolkit — async REST client library and interactive TUI trading terminal
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Thin wrapper around [`arboard`] for writing text to the system clipboard.
//!
//! All errors are returned as `String` so callers can forward them directly
//! to the status bar without pulling in the `arboard` type into every module.

/// Copies `text` to the system clipboard.
///
/// Returns `Ok(())` on success, or an error message that can be shown in the
/// status bar on failure (e.g. when running in a headless environment).
pub fn copy_to_clipboard(text: &str) -> Result<(), String> {
    arboard::Clipboard::new()
        .and_then(|mut cb| cb.set_text(text))
        .map_err(|e| format!("Clipboard error: {e}"))
}