use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RerankResult {
pub index: usize,
pub score: f32,
pub document: String,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn roundtrips_through_serde() {
let r = RerankResult {
index: 3,
score: 0.91,
document: "Rust is memory-safe".into(),
};
let json = serde_json::to_string(&r).unwrap();
let back: RerankResult = serde_json::from_str(&json).unwrap();
assert_eq!(r, back);
}
#[test]
fn preserves_index_for_caller_side_mapping() {
let r = RerankResult {
index: 7,
score: 0.0,
document: String::new(),
};
assert_eq!(r.index, 7);
}
}