Skip to main content

prism_mcp_rs/client/
enhanced_traits.rs

1//! Enhanced trait implementations for better ergonomics
2
3use crate::protocol::types::ClientInfo;
4use std::fmt;
5
6/// Enhanced Display implementation for ClientInfo
7impl fmt::Display for ClientInfo {
8    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9        write!(f, "{} v{}", self.name, self.version)
10    }
11}
12
13/// From implementations for flexible client creation
14impl From<&str> for ClientInfo {
15    fn from(name: &str) -> Self {
16        ClientInfo::new(name.to_string(), "1.0.0".to_string())
17    }
18}
19
20impl From<(&str, &str)> for ClientInfo {
21    fn from((name, version): (&str, &str)) -> Self {
22        ClientInfo::new(name.to_string(), version.to_string())
23    }
24}
25
26// Note: TryFrom<(&str, &str)> conflicts with blanket implementation
27// Use ClientInfo::new() for validation instead