pub struct Validated<T>(/* private fields */);Expand description
Marker that wraps a value proven to satisfy its validation contract.
The only way to obtain Validated<McpServerConfig> is by calling
McpServerConfig::validate, which is the contract enforced at
the type level by serve and serve_with_listener. The
inner field is private, so downstream code cannot bypass
validation by hand-constructing the wrapper.
Validated<T> derefs to &T for read-only access. To mutate,
recover the raw value with Validated::into_inner and
re-validate.
§Example
use rmcp_server_kit::transport::{McpServerConfig, Validated, serve};
use rmcp::handler::server::ServerHandler;
use rmcp::model::{ServerCapabilities, ServerInfo};
#[derive(Clone)]
struct H;
impl ServerHandler for H {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}
}
let config: Validated<McpServerConfig> =
McpServerConfig::new("127.0.0.1:8080", "my-server", "0.1.0").validate()?;
serve(config, || H).awaitForgetting .validate()? is a compile error:
ⓘ
use rmcp_server_kit::transport::{McpServerConfig, serve};
use rmcp::handler::server::ServerHandler;
use rmcp::model::{ServerCapabilities, ServerInfo};
#[derive(Clone)]
struct H;
impl ServerHandler for H {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
}
}
let config = McpServerConfig::new("127.0.0.1:8080", "my-server", "0.1.0");
// Missing `.validate()?` -> mismatched types: expected
// `Validated<McpServerConfig>`, found `McpServerConfig`.
serve(config, || H).awaitImplementations§
Source§impl<T> Validated<T>
impl<T> Validated<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Recover the raw value, discarding the validation proof.
Re-validate before re-using the value with serve or
serve_with_listener.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Validated<T>where
T: Freeze,
impl<T> RefUnwindSafe for Validated<T>where
T: RefUnwindSafe,
impl<T> Send for Validated<T>where
T: Send,
impl<T> Sync for Validated<T>where
T: Sync,
impl<T> Unpin for Validated<T>where
T: Unpin,
impl<T> UnsafeUnpin for Validated<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Validated<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of
Access::load.