Skip to main content

SemanticSignal

Struct SemanticSignal 

Source
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>§tags: Vec<String>§metadata: BTreeMap<String, Value>

Implementations§

Source§

impl SemanticSignal

Source

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
Hide additional 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

Source§

fn clone(&self) -> SemanticSignal

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SemanticSignal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SemanticSignal

Source§

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

Source§

fn eq(&self, other: &SemanticSignal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SemanticSignal

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SemanticSignal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,