pub struct ClipboardContent {
pub payload: ClipboardPayload,
pub source_app: String,
pub captured_at: SystemTime,
}Fields§
§payload: ClipboardPayload§source_app: String§captured_at: SystemTimeImplementations§
Source§impl ClipboardContent
impl ClipboardContent
Sourcepub fn redacted_preview(&self) -> String
pub fn redacted_preview(&self) -> String
Examples found in repository?
examples/assistant_context_adapter.rs (line 164)
160fn print_augmented_packet(api: &ContextApi, state: &Arc<Mutex<AdapterState>>, task: &str) {
161 let snapshot = state.lock().expect("adapter state mutex poisoned").clone();
162 let clipboard_preview = api.read_clipboard_content().ok().map(|content| {
163 // The preview intentionally keeps sensitive content redacted when needed.
164 content.redacted_preview()
165 });
166
167 let packet = build_context_packet(api, &snapshot, task, clipboard_preview.clone());
168 println!();
169 println!("=== Augmented Context Packet ===");
170 println!(
171 "{}",
172 serde_json::to_string_pretty(&packet).unwrap_or_default()
173 );
174 println!();
175 println!("=== Prompt Preview ===");
176 println!(
177 "{}",
178 build_prompt_preview(task, &snapshot, clipboard_preview)
179 );
180 println!();
181}More examples
examples/clipboard_monitor.rs (line 29)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut api = ContextApi::new()?;
7
8 api.subscribe(SignalType::Clipboard, |signal| {
9 println!(
10 "clipboard changed: type={:?}, bytes={}, source={}, sensitive={}, command={}",
11 signal.content_type,
12 signal.size_bytes,
13 signal.source_app,
14 signal.likely_sensitive,
15 signal.likely_command
16 );
17 })?;
18
19 api.request_permission(
20 PermissionRequest::new(
21 Capability::ReadClipboardContent,
22 Scope::Session,
23 "Show how explicit content access works in the example",
24 )
25 .with_ttl(Duration::from_secs(300)),
26 )?;
27
28 if let Ok(content) = api.read_clipboard_content() {
29 println!("initial clipboard preview: {}", content.redacted_preview());
30 }
31
32 println!("Monitoring clipboard changes. Press Ctrl+C to exit.");
33 api.run_with_signals()?;
34 Ok(())
35}Trait Implementations§
Source§impl Clone for ClipboardContent
impl Clone for ClipboardContent
Source§fn clone(&self) -> ClipboardContent
fn clone(&self) -> ClipboardContent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClipboardContent
impl Debug for ClipboardContent
Source§impl<'de> Deserialize<'de> for ClipboardContent
impl<'de> Deserialize<'de> for ClipboardContent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ClipboardContent
impl RefUnwindSafe for ClipboardContent
impl Send for ClipboardContent
impl Sync for ClipboardContent
impl Unpin for ClipboardContent
impl UnsafeUnpin for ClipboardContent
impl UnwindSafe for ClipboardContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more