Skip to main content

ServerConfig

Struct ServerConfig 

Source
pub struct ServerConfig {
    pub root: Option<PathBuf>,
    pub server_name: Option<String>,
    pub no_server_header: bool,
    pub workers: Option<usize>,
    pub tls: Option<TlsConfig>,
    pub compress: Option<CompressConfig>,
    pub allow_http: bool,
    pub acme: Option<AcmeFileConfig>,
    pub hsts: Option<HstsConfig>,
    pub privdrop: Option<PrivDropConfig>,
    /* private fields */
}
Expand description

The parsed server configuration.

Fields§

§root: Option<PathBuf>

Document root for static file serving.

§server_name: Option<String>

Server header value.

§no_server_header: bool

Omit the Server response header entirely. Wins over server_name.

§workers: Option<usize>

Worker thread count (thread-pool runtime).

§tls: Option<TlsConfig>

TLS settings.

§compress: Option<CompressConfig>

Compression settings.

§allow_http: bool

Serve content over plain HTTP instead of redirecting to HTTPS.

§acme: Option<AcmeFileConfig>

Automatic certificate management.

§hsts: Option<HstsConfig>

Strict-Transport-Security settings (sent on secure responses).

§privdrop: Option<PrivDropConfig>

Privilege-dropping settings (drop root after binding; Unix only).

Implementations§

Source§

impl ServerConfig

Source

pub fn from_toml_str(s: &str) -> Result<ServerConfig>

Parse a configuration from a TOML string.

Source

pub fn from_file(path: impl AsRef<Path>) -> Result<ServerConfig>

Read and parse a configuration file.

Source

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

The configured listen addresses, as strings.

Source

pub fn priv_drop(&self) -> Result<Option<PrivDrop>>

Resolve the [privdrop] table into a runnable PrivDrop, if configured.

Because dropping privileges is process-wide and must happen only after every listener (TCP, HTTP redirect, and HTTP/3 UDP) is bound, the actual drop is performed by the caller (the CLI) — not by into_server. This exposes the parsed actions so the binary can apply them once, under the bind-readiness handshake.

Source

pub fn into_server(self) -> Result<Server>

Build a runnable Server from this configuration.

Trait Implementations§

Source§

impl Clone for ServerConfig

Source§

fn clone(&self) -> ServerConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ServerConfig

Source§

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

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

impl<'de> Deserialize<'de> for ServerConfig

Source§

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§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.