Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub port: u16,
    pub max_memory_bytes: u64,
    pub max_stream_bytes: u64,
    pub cors_origins: String,
    pub long_poll_timeout: Duration,
    pub sse_reconnect_interval_secs: u64,
    pub storage_mode: StorageMode,
    pub data_dir: String,
    pub acid_shard_count: usize,
    pub tls_cert_path: Option<String>,
    pub tls_key_path: Option<String>,
    pub rust_log: String,
}
Expand description

Server configuration

Fields§

§port: u16

Port to bind the server to

§max_memory_bytes: u64

Maximum total memory usage in bytes

§max_stream_bytes: u64

Maximum bytes per stream

§cors_origins: String

CORS allowed origins (comma-separated, “*” for all)

§long_poll_timeout: Duration

Long-poll timeout duration

§sse_reconnect_interval_secs: u64

SSE reconnect interval in seconds (0 disables).

Matches Caddy’s sse_reconnect_interval. Connections are closed after this many idle seconds to enable CDN request collapsing.

§storage_mode: StorageMode

Selected storage mode

§data_dir: String

Root directory for file/acid-backed storage.

Matches Caddy’s data_dir.

§acid_shard_count: usize

Number of shards for acid/redb storage mode.

§tls_cert_path: Option<String>

Optional TLS certificate path (PEM). Requires tls_key_path.

§tls_key_path: Option<String>

Optional TLS private key path (PEM or PKCS#8). Requires tls_cert_path.

§rust_log: String

Default log filter when RUST_LOG is not explicitly set.

Implementations§

Source§

impl Config

Source

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

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, String>

Load configuration from layered TOML files plus environment overrides.

Order (later wins):

  1. built-in defaults
  2. config/default.toml (if present)
  3. config/<profile>.toml (if present)
  4. config/local.toml (if present)
  5. --config <path> override file (if provided)
  6. 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<(), String>

Validate configuration invariants before server startup.

§Errors

Returns an error string when config is internally inconsistent.

Source

pub fn tls_enabled(&self) -> bool

True when direct TLS termination is enabled on this server.

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

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<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