pub struct SearchHit {
pub path: String,
pub score: f64,
}Expand description
One search hit’s path and relevance score, as parsed from a
search_code call’s underlying trusty-search response (UI “what drove
this” search-audit detail — DOC-39 Slice B).
Why: Event::SearchPerformed’s hit_count tells the UI HOW MANY files
a search touched but not WHICH ones — the audit trail’s whole point is
tracing a change back to the exact files that surfaced it, and a bare
count cannot answer “was it this file”. tools::trusty_search already
walks every hit out of the raw MCP response once to COUNT it; this struct
carries the same per-hit path/score it already has in hand from that SAME
walk, so no second parse pass is needed.
What: path is the hit’s index-relative path when the lane reports one,
falling back to its absolute path otherwise (see
tools::trusty_search::parse_search_hits for exactly which JSON key is
read per lane). score is the lane’s relevance score reinterpreted as
f64 (matches serde_json::Value::as_f64’s own numeric representation,
regardless of the daemon’s internal f32/f64); it defaults to 0.0
for lanes (e.g. grep) whose hits carry no score at all — a real hit
that is merely unscored, never fabricated data.
Test: search_hit_round_trips_through_json.
Fields§
§path: StringThe hit’s path, as reported by the trusty-search lane that served it.
score: f64The lane’s relevance score for this hit, or 0.0 when the lane
reports no score (e.g. grep).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SearchHit
impl<'de> Deserialize<'de> for SearchHit
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>,
impl StructuralPartialEq for SearchHit
Auto Trait Implementations§
impl Freeze for SearchHit
impl RefUnwindSafe for SearchHit
impl Send for SearchHit
impl Sync for SearchHit
impl Unpin for SearchHit
impl UnsafeUnpin for SearchHit
impl UnwindSafe for SearchHit
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more