pub struct CratesDocsServer { /* private fields */ }Expand description
Crates Docs MCP Server
Main server struct, managing configuration, tool registry, and cache. Supports multiple transport protocols: stdio, HTTP, SSE, Hybrid.
§Fields
config: Application configurationtool_registry: Tool registrycache: Cache instance
Implementations§
Source§impl CratesDocsServer
impl CratesDocsServer
Sourcepub fn new(config: AppConfig) -> Result<Self>
pub fn new(config: AppConfig) -> Result<Self>
Create new server instance (synchronous)
§Arguments
config- Application configuration
§Errors
Returns error if cache creation fails
§Note
This method only supports memory cache. For Redis, use new_async.
§Example
use crates_docs::{AppConfig, CratesDocsServer};
let config = AppConfig::default();
let server = CratesDocsServer::new(config).expect("Failed to create server");Sourcepub async fn new_async(config: AppConfig) -> Result<Self>
pub async fn new_async(config: AppConfig) -> Result<Self>
Create new server instance (async)
§Arguments
config- Application configuration
§Errors
Returns error if cache creation fails
§Note
Supports memory cache and Redis cache (requires cache-redis feature).
§Example
use crates_docs::{AppConfig, CratesDocsServer};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = AppConfig::default();
let server = CratesDocsServer::new_async(config).await?;
Ok(())
}Sourcepub fn tool_registry(&self) -> &Arc<ToolRegistry>
pub fn tool_registry(&self) -> &Arc<ToolRegistry>
Get tool registry
Sourcepub fn server_info(&self) -> InitializeResult
pub fn server_info(&self) -> InitializeResult
Get server info
Returns MCP initialization result with server metadata and capabilities
Trait Implementations§
Source§impl Clone for CratesDocsServer
impl Clone for CratesDocsServer
Source§fn clone(&self) -> CratesDocsServer
fn clone(&self) -> CratesDocsServer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CratesDocsServer
impl !RefUnwindSafe for CratesDocsServer
impl Send for CratesDocsServer
impl Sync for CratesDocsServer
impl Unpin for CratesDocsServer
impl UnsafeUnpin for CratesDocsServer
impl !UnwindSafe for CratesDocsServer
Blanket Implementations§
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