pub struct ServerConfig {
pub name: String,
pub version: String,
pub description: Option<String>,
pub bind_address: String,
pub port: u16,
pub enable_tls: bool,
pub tls: Option<TlsConfig>,
pub timeouts: TimeoutConfig,
pub rate_limiting: RateLimitingConfig,
pub logging: LoggingConfig,
pub additional: HashMap<String, Value>,
}Expand description
Server configuration
Fields§
§name: StringServer name
version: StringServer version
description: Option<String>Server description
bind_address: StringBind address
port: u16Bind port
enable_tls: boolEnable TLS
tls: Option<TlsConfig>TLS configuration
timeouts: TimeoutConfigTimeout configuration
rate_limiting: RateLimitingConfigRate limiting configuration
logging: LoggingConfigLogging configuration
additional: HashMap<String, Value>Additional configuration
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self, ConfigError>
Load configuration from a file (TOML, YAML, or JSON)
The file format is auto-detected from the file extension:
.toml→ TOML format.yamlor.yml→ YAML format.json→ JSON format
Environment variables with the TURBOMCP_ prefix will override file settings.
For example, TURBOMCP_PORT=9000 will override the port setting.
§Example
use turbomcp_server::ServerConfig;
let config = ServerConfig::from_file("config.toml").expect("Failed to load config");§Errors
Returns an error if:
- The file doesn’t exist
- The file format is unsupported
- The file contains invalid configuration
Sourcepub fn from_file_with_prefix(
path: impl AsRef<Path>,
env_prefix: &str,
) -> Result<Self, ConfigError>
pub fn from_file_with_prefix( path: impl AsRef<Path>, env_prefix: &str, ) -> Result<Self, ConfigError>
Load configuration from a file with custom environment prefix
§Example
use turbomcp_server::ServerConfig;
// Use MYAPP_PORT instead of TURBOMCP_PORT
let config = ServerConfig::from_file_with_prefix("config.toml", "MYAPP")
.expect("Failed to load config");Sourcepub fn builder() -> ConfigurationBuilder
pub fn builder() -> ConfigurationBuilder
Create a configuration builder
Use this for programmatic configuration without files.
§Example
use turbomcp_server::ServerConfig;
let config = ServerConfig::builder()
.name("my-server")
.port(9000)
.build();Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
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 moreSource§impl Debug for ServerConfig
impl Debug for ServerConfig
Source§impl Default for ServerConfig
impl Default for ServerConfig
Source§impl<'de> Deserialize<'de> for ServerConfig
impl<'de> Deserialize<'de> for ServerConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnwindSafe for ServerConfig
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