Skip to content

Commit

Permalink
feat: clipboard rust guide #1475 (#1622)
Browse files Browse the repository at this point in the history
* create rust guide

* update invoke import

* simplify rust guide

* simplify even more to match it to JS
  • Loading branch information
vasfvitor authored Nov 6, 2023
1 parent 192cede commit 963d607
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/content/docs/features/clipboard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Install the clipboard plugin to get started.
}
```



</TabItem>
<TabItem label="Manual">

Expand Down Expand Up @@ -84,10 +86,10 @@ The clipboard plugin is available in both JavaScript and Rust.
```js
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';

// Write text to the clipboard
// Write content to clipboard
await writeText('Tauri is awesome!');

// Read text from the clipboard
// Read content from clipboard
const content = await readText();
console.log(content);
// Prints "Tauri is awesome!" to the console
Expand All @@ -96,9 +98,23 @@ console.log(content);
</TabItem>
<TabItem label="Rust">

{/* TODO: */}
```rust
use tauri_plugin_clipboard_manager::ClipboardExt;

// Write content to clipboard
let clipboard_content = tauri_plugin_clipboard_manager::ClipKind::PlainText {
label: Some("Label".to_string()),
text: "Tauri is awesome!".to_string(),
};
app.clipboard().write(clipboard_content).unwrap();

<Stub />
// Read content from clipboard
let content = app.clipboard().read();
println!("{:?}", content.unwrap());
// Prints "Tauri is awesome!" to the terminal


```

</TabItem>
</Tabs>

0 comments on commit 963d607

Please sign in to comment.