-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmissing_data.rs
More file actions
60 lines (50 loc) · 1.52 KB
/
missing_data.rs
File metadata and controls
60 lines (50 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Missing data reporting schemas
use schemars::JsonSchema;
use serde::Deserialize;
use crate::tool_result;
use crate::tools::Validate;
/// Parameters for reporting missing data
#[derive(Deserialize, JsonSchema)]
pub struct MissingDataParams {
/// Type of data needed (e.g., 'API documentation', 'database schema')
pub data_type: String,
/// Why this data is required
pub reason: String,
/// Additional optional context about the missing information
#[serde(default)]
pub context: Option<String>,
}
impl Validate for MissingDataParams {}
tool_result! {
name = "missing-data",
params = MissingDataParams,
/// Result of reporting missing data
pub struct MissingDataResult {
data_type: String,
reason: String,
#[serde(default)]
context: Option<String>,
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tools::ToolResult;
#[test]
fn test_result_has_correct_name() {
assert_eq!(MissingDataResult::NAME, "missing-data");
}
#[test]
fn test_params_converts_to_result() {
let params = MissingDataParams {
data_type: "API docs".to_string(),
reason: "needed for integration".to_string(),
context: None,
};
let result: MissingDataResult = params.try_into().unwrap();
assert_eq!(result.name, "missing-data");
assert_eq!(result.data_type, "API docs");
assert_eq!(result.reason, "needed for integration");
assert_eq!(result.context, None);
}
}