Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 25 fields pub app_name: String, pub app_env: String, pub app_port: u16, pub session_secure_cookie: bool, pub app_debug: bool, pub app_url: String, pub app_locale: String, pub app_fallback_locale: String, pub api_prefix: String, pub mail_driver: String, pub mail_host: String, pub mail_port: u16, pub mail_username: String, pub mail_password: String, pub mail_encryption: String, pub mail_from_address: String, pub mail_from_name: String, pub cache_driver: String, pub queue_driver: String, pub log_channel: String, pub log_level: String, pub log_max_size: u64, pub log_keep_files: u32, pub deploy_type: String, pub session_driver: String,
}

Fields§

§app_name: String§app_env: String§app_port: u16§session_secure_cookie: bool

Whether the session cookie carries the Secure attribute. Defaults to true (safe over any real deployment). Browsers only treat loopback addresses and the literal name localhost as secure contexts over plain HTTP - a custom local dev hostname (e.g. a .test domain resolved via /etc/hosts, even one that points at 127.0.0.1) is not on that list, so the Secure cookie is silently dropped by the browser and sessions/CSRF stop working with no error surfaced anywhere. Set SESSION_SECURE_COOKIE=false for that case.

§app_debug: bool

Gates descriptive error pages (the full error message and source chain, rendered as HTML) and panic details. Defaults to false - safe if unset, so a deployment missing both .env and its own config/app.rs’s APP_DEBUG handling never leaks internals by accident. Scaffolded apps ship APP_DEBUG=true in their own .env for local dev, mirroring Laravel’s own scaffold convention.

§app_url: String

The app’s own base URL, for larust_support::url()/asset() to build absolute URLs from a relative path. Defaults to "http://localhost" - matching Laravel’s own scaffolded default exactly (no port; most local dev never needs url() to be port-precise). Set APP_URL for anything that does.

§app_locale: String

larust_lang::current_locale’s own default when no per-request override is set (see that crate’s own doc comment) - Laravel’s config('app.locale')/APP_LOCALE. Defaults to "en".

§app_fallback_locale: String

larust_lang::t/t_with’s fallback when a key is missing from the current locale’s own translation file - Laravel’s config('app.fallback_locale')/APP_FALLBACK_LOCALE. Defaults to "en", same as app_locale - most apps only ever have one locale until they add a second, at which point this is usually still the original one.

§api_prefix: String

Where routes/api.rs gets mounted (main.rs’s .group(&config.api_prefix, ...) call) - Laravel’s own routes/api.php is likewise served under a configurable prefix (RouteServiceProvider’s apiPrefix), not a fixed one. Defaults to "/api".

§mail_driver: String

"log" (default) writes a mail’s rendered subject/body to tracing::info! instead of sending it - no network touched, no SMTP server needed for local dev or cargo test, matching Laravel’s own MAIL_MAILER=log scaffold default exactly. "smtp" sends for real, using the fields below.

§mail_host: String§mail_port: u16§mail_username: String

Empty string means “unset” - Config has no Option<T> field precedent elsewhere, and the log driver (the default) never reads these anyway.

§mail_password: String§mail_encryption: String§mail_from_address: String§mail_from_name: String

Falls back to app_name if unset, matching Laravel’s own MAIL_FROM_NAME="${APP_NAME}" scaffold default.

§cache_driver: String

"database" (default) stores larust-cache’s entries in cache_items, the same SQL-family table it has always used. "redis" stores them in Redis instead - see larust-cache::store’s own doc comment for the split. Same mail_driver-shaped “a plain string picks a runtime code path” convention, not a typed enum: larust-core has no sqlx/redis dependency and shouldn’t need one just to name a driver.

§queue_driver: String

larust-queue’s own driver toggle - see cache_driver’s own doc comment for the shape and reasoning; independent of it (an app can mix a database-backed cache with a Redis-backed queue, or vice versa).

§log_channel: String

"stdout" (default) - everything goes to the terminal via tracing_subscriber::fmt, exactly as before this field existed. "file" writes to storage/logs/larust.log instead (rotated - see log_max_size); "stack" writes to both, the same “combine channels” meaning Laravel’s own LOG_CHANNEL=stack has. Laravel additionally supports single/daily/slack/etc. channels this doesn’t attempt - see crate::logging’s own module doc comment for why size-based rotation was the one strategy actually built.

§log_level: String

Empty string means “unset” (same convention as mail_username) - falls back to this crate’s own historical behavior: debug,sqlx=warn,tower_sessions=warn in app_env == "local", info otherwise. Set to a plain level name (trace/debug/info/warn/error) to override that for every crate at once; sqlx/tower_sessions are still individually capped at warn even then, for the same reason init_logging’s own hardcoded default already did - see crate::logging’s doc comment. RUST_LOG, if set, wins over this unconditionally, same as it already won over the old hardcoded default.

§log_max_size: u64

Bytes - once storage/logs/larust.log reaches this size, it’s rotated to larust.log.1 (shifting any existing .1/.2/… down one) and a fresh, empty file is started. Only consulted when log_channel is "file"/"stack". Defaults to 10 MiB.

§log_keep_files: u32

How many rotated backups (larust.log.1 through larust.log.{N}) to keep before the oldest is deleted outright. 0 means “delete immediately on rotation, keep only the current file.” Defaults to 5.

§deploy_type: String

"web" (default) - an ordinary server, deployed via xr deploy‘s build-and-restart-handoff path. "app" - a Tauri desktop build, where the app’s own Application/router is spawned in-process and a native webview points at it locally instead of a browser connecting over the network. Read by xr deploy/xr new (from .env, not through this struct - see those crates’ own doc comments for why), not by this crate itself; kept on Config mainly so app code (e.g. a template wanting to render different chrome for a desktop build) can read app.config().deploy_type like any other setting.

§session_driver: String

"database" (default) - sessions live in whatever DB_CONNECTION points at, via larust_http::session::AnySessionStore. "file" - one file per session under storage/sessions/ (larust_http::session::FileSessionStore), Laravel’s own SESSION_DRIVER=file equivalent: real persistence across a restart/crash (unlike an in-memory store, which this framework deliberately never offers - see larust_http::session’s own module doc comment), just not through the app’s database. A genuinely reasonable choice for a single-server app that would rather not put session churn through its own database at all - see docs/the-basics/middleware-sessions-and-csrf.md. Any other value is treated the same as an unset LOG_CHANNEL (see that field’s own doc comment on the identical “unrecognized degrades to the safe default” precedent) - falls back to "database", but (unlike LOG_CHANNEL) Application::new() warns about it first, since a silently-ignored SESSION_DRIVER value was a real, reported production confusion before that warning existed.

Implementations§

Source§

impl Config

Source

pub fn from_value(value: &Value) -> Result<Self, AppError>

Builds Config from value - the serde_json::Value an app’s own generated config/app.rs (pub fn config() -> Value) produces. A single serde_json::from_value call: Config already derives Deserialize with a #[serde(default = ...)] per field, which works identically regardless of the source Deserializer (this used to be TOML, read from config/app.toml - see this crate’s git history), so no manual field-by-field extraction is needed here. Env-var override capability (Laravel’s own “config file sets a default, .env can override it” behavior) lives entirely in the generated config/app.rs’s own env_or/env_bool calls now - this function has no knowledge of environment variables at all, unlike the TOML-era load_from it replaced.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

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 Config

Source§

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

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

impl<'de> Deserialize<'de> for Config

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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