rigela_utils/
clip.rs

1/*
2 * Copyright (c) 2024. The RigelA open source project team and
3 * its contributors reserve all rights.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and limitations under the License.
12 */
13
14use clipboard::{ClipboardContext, ClipboardProvider};
15
16/**
17 * 获取剪贴板文本数据。
18 * */
19pub fn get_clipboard_text() -> String {
20    let mut ctx = ClipboardContext::new().unwrap();
21    ctx.get_contents().unwrap()
22}
23
24/**
25 * 设置剪贴板文本数据。
26 * `text` 数据内容。
27 * */
28pub fn set_clipboard_text(text: String) {
29    let mut ctx = ClipboardContext::new().unwrap();
30    ctx.set_contents(text).unwrap()
31}