Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub server: ServerConfig,
    pub limits: LimitsConfig,
    pub http: HttpConfig,
    pub storage: StorageConfig,
    pub transport: TransportConfig,
    pub proxy: ProxyConfig,
    pub observability: ObservabilityConfig,
}
Expand description

Server configuration resolved after all layering and defaults.

Fields§

§server: ServerConfig

Listener settings.

§limits: LimitsConfig

Stream and storage size limits.

§http: HttpConfig

HTTP protocol surface configuration.

§storage: StorageConfig

Persistence backend configuration.

§transport: TransportConfig

Transport and connection behaviour.

§proxy: ProxyConfig

Reverse-proxy trust and identity handoff.

§observability: ObservabilityConfig

Logging and tracing defaults.

Implementations§

Source§

impl Config

Source

pub fn from_env() -> Result<Self, ConfigLoadError>

Load configuration from DS_* environment variables with sensible defaults.

Used by tests and as a simple entry point when TOML layering is not needed.

§Errors

Returns an error when any DS_* environment variable is present but invalid.

Source

pub fn from_sources( options: &ConfigLoadOptions, ) -> Result<Self, ConfigLoadError>

Load configuration from layered TOML files plus environment overrides.

Order (later wins):

  1. built-in defaults
  2. built-in profile defaults
  3. config/default.toml (if present)
  4. config/<profile>.toml (if present)
  5. config/local.toml (if present)
  6. --config <path> override file (if provided)
  7. DS_* env vars
§Errors

Returns an error when config files cannot be parsed or an explicit override file path does not exist/read.

Source

pub fn validate(&self) -> Result<(), ConfigValidationError>

Validate configuration invariants before server startup.

§Errors

Returns a typed validation error when config is internally inconsistent.

Source

pub fn validate_profile( &self, profile: &DeploymentProfile, ) -> Result<(), ConfigValidationError>

Deployment-profile-specific validation run after Config::validate.

Production profiles (prod, prod-tls, prod-mtls) reject wildcard CORS unless the operator has explicitly set http.allow_wildcard_cors.

§Errors

Returns ConfigValidationError::WildcardCorsOriginsProd when a production profile is active with cors_origins = "*" and the escape hatch is not set.

Source

pub fn warnings(&self) -> Vec<String>

Non-fatal advisories about the current configuration.

Returns human-readable warning strings that should be logged at startup but do not block the server from starting. Currently checks for wildcard CORS without an explicit opt-in via http.allow_wildcard_cors.

Source

pub fn tls_enabled(&self) -> bool

True when direct TLS termination is enabled on this server.

Source

pub fn bind_socket_addr(&self) -> Result<SocketAddr, ConfigValidationError>

Parsed bind address used by the runtime.

§Errors

Returns the same validation error that Config::validate would emit for an invalid bind address.

Source

pub fn long_poll_timeout(&self) -> Duration

Long-poll timeout as a typed Duration.

Source

pub fn render_effective_json(&self) -> Result<String, Error>

Render the effective merged configuration as pretty JSON.

§Errors

Returns an error when the effective config cannot be serialized.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Config

Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more