use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub struct MemoryTool {
pub kind: String,
}
impl MemoryTool {
pub const KIND: &'static str = "memory";
#[must_use]
pub fn new() -> Self {
Self {
kind: Self::KIND.into(),
}
}
#[must_use]
pub fn kind() -> &'static str {
Self::KIND
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_memory_tool_new() {
let tool = MemoryTool::new();
assert_eq!(tool.kind, "memory");
}
#[test]
fn test_memory_tool_kind() {
assert_eq!(MemoryTool::kind(), "memory");
}
#[test]
fn test_memory_tool_default() {
let tool = MemoryTool::default();
assert_eq!(tool.kind, "");
}
#[test]
fn test_memory_tool_serialize() {
let tool = MemoryTool::new();
let json = serde_json::to_string(&tool).unwrap();
assert!(json.contains("\"kind\":\"memory\""));
}
#[test]
fn test_memory_tool_deserialize() {
let json = r#"{"kind":"memory"}"#;
let tool: MemoryTool = serde_json::from_str(json).unwrap();
assert_eq!(tool.kind, "memory");
}
}