Skip to main content

hanzo_client/models/
span.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct Span {
16    /// EndLine is the last line of the span, inclusive. It equals Line for a one-line span rather than being zero or absent.
17    #[serde(rename = "endLine", skip_serializing_if = "Option::is_none")]
18    pub end_line: Option<i32>,
19    /// File is the path inside the repo, relative to its root and never absolute.
20    #[serde(rename = "file", skip_serializing_if = "Option::is_none")]
21    pub file: Option<String>,
22    /// Kind is what the indexer decided this chunk IS — \"func\", \"method\", \"type\", \"struct\", \"interface\", \"var\", \"const\", or \"block\" for a run of code that declares nothing. Absent when the chunker could not classify it.
23    #[serde(rename = "kind", skip_serializing_if = "Option::is_none")]
24    pub kind: Option<String>,
25    /// Line is where the span starts, 1-based, as an editor counts.
26    #[serde(rename = "line", skip_serializing_if = "Option::is_none")]
27    pub line: Option<i32>,
28    /// Repo is the indexed repository the span was found in, as it was indexed (\"owner/name\"). A search may be scoped to one repo or run across all of them, so this is how a caller tells the results apart.
29    #[serde(rename = "repo", skip_serializing_if = "Option::is_none")]
30    pub repo: Option<String>,
31    /// context: match | definition | caller
32    #[serde(rename = "role", skip_serializing_if = "Option::is_none")]
33    pub role: Option<String>,
34    /// Score ranks this span against the OTHERS IN THE SAME RESPONSE and means nothing across responses or between tiers: the hybrid tier's number is a reciprocal-rank fusion sum (Σ 1/(60+rank), so tenths at best), the symbol tier's is a descending position count, and the text and semantic tiers pass through bm25 and cosine. Compare within a list; never threshold on it.
35    #[serde(rename = "score", skip_serializing_if = "Option::is_none")]
36    pub score: Option<f64>,
37    /// Snippet is the code itself: a bounded excerpt on /search, the whole chunk on /context — which is why the same type serves both and why a /context span is the one an agent pastes into its window.
38    #[serde(rename = "snippet", skip_serializing_if = "Option::is_none")]
39    pub snippet: Option<String>,
40    /// Symbol is the declared name, when the span declares one. Absent on a block.
41    #[serde(rename = "symbol", skip_serializing_if = "Option::is_none")]
42    pub symbol: Option<String>,
43    /// Tier is which retrieval produced the span: \"hybrid\" (the default — all three fused), \"text\" (trigram/FTS), \"regex\", \"semantic\" (vector), or \"symbol\". It is what explains a Score, so the two travel together.
44    #[serde(rename = "tier", skip_serializing_if = "Option::is_none")]
45    pub tier: Option<String>,
46}
47
48impl Span {
49    pub fn new() -> Span {
50        Span {
51            end_line: None,
52            file: None,
53            kind: None,
54            line: None,
55            repo: None,
56            role: None,
57            score: None,
58            snippet: None,
59            symbol: None,
60            tier: None,
61        }
62    }
63}
64