moon add mst-mkt/clipboardasync test "read and write" {
let cb = @clipboard.Clipboard::new_in_memory()
cb.set_text("hello")
inspect(cb.get_text(), content="hello")
}@async.with_task_group(group => {
let cb = @clipboard.Clipboard::new()
let handle = cb.watch(group, value => println("clipboard changed: \{value}"))
// ... later
handle.stop()
})| Function | Description |
|---|---|
| Clipboard::new() | Bind to the host OS's native backend (detects the OS, may spawn uname). |
| Clipboard::new_in_memory() | In-memory clipboard; never raises. |
| get_text() | Read clipboard text. |
| set_text(text) | Write clipboard text. |
| watch(group, on_change) | Poll for changes; returns a Handle. |
| Handle::stop() | Stop a watcher. |
pub(open) trait Backend {
async fn get_text(Self) -> String raise ClipboardError
async fn set_text(Self, String) -> Unit raise ClipboardError
}pub struct Clipboard {
// private fields
}