pub struct SemanticSignal {
pub version: String,
pub occurred_at: String,
pub source: String,
pub action: SignalAction,
pub entity_kind: EntityKind,
pub summary: String,
pub confidence: f32,
pub paths: Vec<String>,
pub tags: Vec<String>,
pub metadata: BTreeMap<String, Value>,
}Fields§
§version: String§occurred_at: String§source: String§action: SignalAction§entity_kind: EntityKind§summary: String§confidence: f32§paths: Vec<String>§metadata: BTreeMap<String, Value>Implementations§
Source§impl SemanticSignal
impl SemanticSignal
Sourcepub fn event_name(&self) -> String
pub fn event_name(&self) -> String
Examples found in repository?
examples/context_live_view.rs (line 106)
82fn summarize_envelope(envelope: &SignalEnvelope) -> String {
83 let secs = envelope
84 .emitted_at
85 .duration_since(UNIX_EPOCH)
86 .map(|duration| duration.as_secs())
87 .unwrap_or_default();
88
89 let summary = match &envelope.payload {
90 StructuralSignal::Clipboard(signal) => format!(
91 "clipboard type={:?} bytes={} source={}",
92 signal.content_type, signal.size_bytes, signal.source_app
93 ),
94 StructuralSignal::Selection(signal) => format!(
95 "selection type={:?} bytes={} source={}",
96 signal.content_type, signal.size_bytes, signal.source_app
97 ),
98 StructuralSignal::Focus(signal) => {
99 format!(
100 "focus target={:?} source={}",
101 signal.target, signal.source_app
102 )
103 }
104 StructuralSignal::Filesystem(signal) => format!(
105 "filesystem event={} action={:?}",
106 signal.event_name(),
107 signal.action
108 ),
109 };
110
111 format!("{secs} {summary}")
112}More examples
examples/assistant_context_adapter.rs (line 126)
88fn ingest_envelope(state: &Arc<Mutex<AdapterState>>, envelope: SignalEnvelope) {
89 let mut state = state.lock().expect("adapter state mutex poisoned");
90 let ts = unix_secs(envelope.emitted_at);
91
92 match envelope.payload {
93 StructuralSignal::Clipboard(signal) => {
94 let summary = format!(
95 "clipboard type={:?} bytes={} sensitive={} command={} source={}",
96 signal.content_type,
97 signal.size_bytes,
98 signal.likely_sensitive,
99 signal.likely_command,
100 signal.source_app
101 );
102 state.recent_clipboard = Some(summary.clone());
103 push_event(&mut state.recent_events, format!("{ts} {summary}"));
104 }
105 StructuralSignal::Selection(signal) => {
106 let preview = format!(
107 "selection type={:?} bytes={} editable={} source={}",
108 signal.content_type, signal.size_bytes, signal.is_editable, signal.source_app
109 );
110 state.recent_selection = Some(preview.clone());
111 push_event(&mut state.recent_events, format!("{ts} {preview}"));
112 }
113 StructuralSignal::Focus(signal) => {
114 let summary = format!(
115 "focus target={:?} editable={} source={}",
116 signal.target, signal.is_editable, signal.source_app
117 );
118 state.recent_focus = Some(summary.clone());
119 push_event(&mut state.recent_events, format!("{ts} {summary}"));
120 }
121 StructuralSignal::Filesystem(signal) => {
122 push_event(
123 &mut state.recent_events,
124 format!(
125 "{ts} filesystem {} {:?}",
126 signal.event_name(),
127 signal.action
128 ),
129 );
130 }
131 }
132}Trait Implementations§
Source§impl Clone for SemanticSignal
impl Clone for SemanticSignal
Source§fn clone(&self) -> SemanticSignal
fn clone(&self) -> SemanticSignal
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 SemanticSignal
impl Debug for SemanticSignal
Source§impl<'de> Deserialize<'de> for SemanticSignal
impl<'de> Deserialize<'de> for SemanticSignal
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
Source§impl PartialEq for SemanticSignal
impl PartialEq for SemanticSignal
Source§impl Serialize for SemanticSignal
impl Serialize for SemanticSignal
impl StructuralPartialEq for SemanticSignal
Auto Trait Implementations§
impl Freeze for SemanticSignal
impl RefUnwindSafe for SemanticSignal
impl Send for SemanticSignal
impl Sync for SemanticSignal
impl Unpin for SemanticSignal
impl UnsafeUnpin for SemanticSignal
impl UnwindSafe for SemanticSignal
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