pub struct Settings {Show 18 fields
pub database_url: String,
pub databases: HashMap<String, String>,
pub max_form_body_bytes: Option<usize>,
pub db_max_connections: u32,
pub db_acquire_timeout_secs: u64,
pub db_min_connections: u32,
pub db_idle_timeout_secs: Option<u64>,
pub db_max_lifetime_secs: Option<u64>,
pub db_test_before_acquire: bool,
pub secret_key: String,
pub environment: Environment,
pub allowed_hosts: Vec<String>,
pub log_level: String,
pub bind_addr: String,
pub time_zone: Option<String>,
pub static_url: String,
pub static_root: String,
pub extra: HashMap<String, Value>,
}Fields§
§database_url: String§databases: HashMap<String, String>§max_form_body_bytes: Option<usize>Max request-body size (bytes) the Form<T> extractor buffers before
returning 413 Payload Too Large. Default 16 MiB (8× the old
hardcoded 2 MiB). Set UMBRAL_MAX_FORM_BODY_BYTES (or max_form_body_bytes
in umbral.toml); set it to 0 to disable the cap entirely — handy
in dev. (For large uploads use a file field / the storage backend, not
the form extractor.)
db_max_connections: u32Max connections in the Postgres pool (PERF-5). Default 10. Set via
UMBRAL_DB_MAX_CONNECTIONS or db_max_connections in umbral.toml.
db_acquire_timeout_secs: u64Seconds to wait for a free pooled connection before failing the
request (Postgres acquire timeout, PERF-5). Default 30. Set via
UMBRAL_DB_ACQUIRE_TIMEOUT_SECS or db_acquire_timeout_secs.
db_min_connections: u32Idle-connection floor — the pool keeps at least this many warm
connections (gaps2 #91). Default 0. Set via
UMBRAL_DB_MIN_CONNECTIONS or db_min_connections.
db_idle_timeout_secs: Option<u64>Close a connection after it’s been idle this many seconds (gaps2
#91). Default 600 (10 min). 0/empty disables idle reaping. Set
via UMBRAL_DB_IDLE_TIMEOUT_SECS or db_idle_timeout_secs.
db_max_lifetime_secs: Option<u64>Recycle a connection older than this many seconds (gaps2 #91).
Default 1800 (30 min) — avoids stale connections behind a load
balancer / Postgres idle-reaping. 0/empty disables. Set via
UMBRAL_DB_MAX_LIFETIME_SECS or db_max_lifetime_secs.
db_test_before_acquire: boolHealth-check a pooled connection before handing it out (gaps2
#91). Default true. Set via UMBRAL_DB_TEST_BEFORE_ACQUIRE or
db_test_before_acquire.
secret_key: String§environment: Environment§allowed_hosts: Vec<String>§log_level: String§bind_addr: StringThe address the development server binds to.
host:port format, e.g. 127.0.0.1:8000 (default), 0.0.0.0:80,
[::1]:8000. Override with UMBRAL_BIND_ADDR or umbral.toml.
time_zone: Option<String>Gap 106 — timezone for marshalling naive datetimes on the
read and write boundary. None (default) keeps the
historical UTC-everywhere behaviour: naive input is treated
as UTC, admin-form display renders the stored UTC value
verbatim.
Some("Africa/Nairobi") (any IANA tz name resolvable via
chrono-tz) flips both ends: HTML <input type="datetime- local"> values arriving naive are interpreted in the
configured tz then converted to UTC before storage; the
admin form renders stored UTC values converted back to the
configured tz so the user sees wall-clock time, not UTC.
Column type stays TIMESTAMPTZ (Postgres) / TEXT
(SQLite) — only the marshalling layer changes.
Set via UMBRAL_TIME_ZONE=Africa/Nairobi or
time_zone = "Africa/Nairobi" in umbral.toml. An unknown
tz name falls back to UTC at lookup time with a tracing
warning rather than panicking — startup never fails on a
tz config error.
static_url: StringURL prefix every collected/served static asset hangs under.
Default "/static/". The framework’s static handler mounts at
this base and the static() template helper prepends it, so
{{ static("admin/admin.css") }} resolves to
"/static/admin/admin.css". Set a CDN origin
(UMBRAL_STATIC_URL=https://cdn.example.com/s/) to serve assets
off a separate host in production — the helper then emits
absolute URLs and the local handler simply goes unused.
Always normalised to carry exactly one leading and one trailing
slash: "/static", "static", and "/static/" all converge on
"/static/". Set via UMBRAL_STATIC_URL or static_url in
umbral.toml.
static_root: StringOn-disk directory collected static assets live under in production.
Default "staticfiles/" (relative to the binary’s CWD). The
static handler resolves a request /static/<ns>/<rest> to
<static_root>/<ns>/<rest> in prod, and as the dev fallback
when a plugin’s live source dir doesn’t have the file. Set via
UMBRAL_STATIC_ROOT or static_root in umbral.toml.
extra: HashMap<String, Value>Catch-all for UMBRAL_-prefixed environment variables (and
umbral.toml keys) that don’t map to a named field above.
Real apps usually need keys the framework doesn’t know about —
OPENAI_API_KEY, STRIPE_SECRET, third-party plugin
configuration. Setting UMBRAL_OPENAI_API_KEY=sk-test makes
settings.extra.get("openai_api_key") return a string value
without the user crate having to wire a second figment loader.
Values are stored as toml::Value so a nested
[external.openai] table in umbral.toml round-trips with its
structure intact. The accessor Settings::extra_str handles
the common scalar-string case.
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn extra_str(&self, key: &str) -> Option<&str>
pub fn extra_str(&self, key: &str) -> Option<&str>
Read a scalar string from the extra map by key. Returns
None if the key is absent or the value isn’t a string.
Most app-defined settings are scalar (UMBRAL_OPENAI_API_KEY= sk-test), so this helper is the right shape for the common
case. For nested tables ([external.openai] in umbral.toml)
the caller indexes into extra directly: settings.extra. get("external").and_then(|v| v.get("openai")).and_then(...).
Sourcepub fn from_env() -> Result<Self, Box<Error>>
pub fn from_env() -> Result<Self, Box<Error>>
Load settings from defaults, .env, umbral.toml, and UMBRAL_-prefixed env vars.
Precedence (later wins): struct defaults → umbral.toml → env vars. A
local .env file is merged as an environment-shaped provider first,
but existing process env vars keep precedence over values from .env.
Implementation uses merge (not join) for both providers so each
subsequent source overrides the previous one’s values. With join
the first provider to set a key would keep it, which would invert
the documented precedence.
The error type is boxed because figment::Error is large (over 200
bytes); see clippy::result_large_err.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Settings
impl<'de> Deserialize<'de> for Settings
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>,
Auto Trait Implementations§
impl Freeze for Settings
impl RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl UnsafeUnpin for Settings
impl UnwindSafe for Settings
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);