Skip to main content

ClipboardProvider

Trait ClipboardProvider 

Source
pub trait ClipboardProvider {
    // Required methods
    fn get_text(&mut self) -> Option<String>;
    fn set_text(&mut self, text: &str) -> bool;

    // Provided methods
    fn get_html(&mut self) -> Option<String> { ... }
    fn set_html(&mut self, _html: &str, _alt_text: Option<&str>) -> bool { ... }
    fn get_image(&mut self) -> Option<ClipboardImage> { ... }
    fn set_image(&mut self, _image: &ClipboardImage) -> bool { ... }
    fn get_file_list(&mut self) -> Option<Vec<PathBuf>> { ... }
    fn set_file_list(&mut self, _paths: &[PathBuf]) -> bool { ... }
}
Expand description

剪贴板抽象 trait。core 层不依赖任何第三方剪贴板 crate。

组件只需要纯文本;富剪贴板(HTML/图片/文件列表)由应用层通过默认方法使用, 平台不支持时保持 None/false。

Required Methods§

Source

fn get_text(&mut self) -> Option<String>

从系统剪贴板读纯文本;不可用(无权限/不支持/初始化失败)返回 None

Source

fn set_text(&mut self, text: &str) -> bool

向系统剪贴板写纯文本;成功返回 true

Provided Methods§

Source

fn get_html(&mut self) -> Option<String>

读取 HTML(通常同时带纯文本 alternative)。

Source

fn set_html(&mut self, _html: &str, _alt_text: Option<&str>) -> bool

写入 HTML 与可选纯文本 alternative。

Source

fn get_image(&mut self) -> Option<ClipboardImage>

Source

fn set_image(&mut self, _image: &ClipboardImage) -> bool

Source

fn get_file_list(&mut self) -> Option<Vec<PathBuf>>

Source

fn set_file_list(&mut self, _paths: &[PathBuf]) -> bool

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§