#[non_exhaustive]pub struct Settings {Show 14 fields
pub core: CoreSettings,
pub templates: Vec<TemplateConfig>,
pub static_url: String,
pub static_root: Option<PathBuf>,
pub staticfiles_dirs: Vec<PathBuf>,
pub media_url: String,
pub media_root: Option<PathBuf>,
pub language_code: String,
pub time_zone: String,
pub use_i18n: bool,
pub use_tz: bool,
pub default_auto_field: String,
pub admins: Vec<Contact>,
pub managers: Vec<Contact>,
}use CoreSettings fragment with ProjectSettings instead
conf and non-WebAssembly only.Expand description
Main settings structure for a Reinhardt project
Deprecated since 0.2.0: Use CoreSettings fragment with
ProjectSettings instead. This struct is retained as a migration bridge
and implements HasCoreSettings so existing code can be gradually
moved to the composable settings system.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.core: CoreSettingsuse CoreSettings fragment with ProjectSettings instead
Core settings (flattened for backward-compatible TOML deserialization).
templates: Vec<TemplateConfig>use CoreSettings fragment with ProjectSettings instead
Template engine configurations.
Note: Currently not consumed by the framework. Reserved for future template engine integration. Setting this value has no effect on framework behavior.
static_url: Stringuse CoreSettings fragment with ProjectSettings instead
Static files URL prefix.
static_root: Option<PathBuf>use CoreSettings fragment with ProjectSettings instead
Static files root directory.
staticfiles_dirs: Vec<PathBuf>use CoreSettings fragment with ProjectSettings instead
Additional static files directories (STATICFILES_DIRS).
media_url: Stringuse CoreSettings fragment with ProjectSettings instead
Media files URL prefix.
media_root: Option<PathBuf>use CoreSettings fragment with ProjectSettings instead
Media files root directory.
language_code: Stringuse CoreSettings fragment with ProjectSettings instead
Language code for internationalization.
Note: Currently not consumed by the framework. Reserved for future i18n implementation. Setting this value has no effect on framework behavior.
time_zone: Stringuse CoreSettings fragment with ProjectSettings instead
Time zone for datetime handling.
Note: Currently not consumed by the framework. Reserved for future timezone support implementation. Setting this value has no effect on framework behavior.
use_i18n: booluse CoreSettings fragment with ProjectSettings instead
Enable internationalization.
Note: Currently not consumed by the framework. Reserved for future i18n implementation. Setting this value has no effect on framework behavior.
use_tz: booluse CoreSettings fragment with ProjectSettings instead
Use timezone-aware datetimes.
Note: Currently not consumed by the framework. Reserved for future timezone support implementation. Setting this value has no effect on framework behavior.
default_auto_field: Stringuse CoreSettings fragment with ProjectSettings instead
Default auto field type for models.
Note: Currently not consumed by the framework. Reserved for future auto field configuration. Setting this value has no effect on framework behavior.
admins: Vec<Contact>use CoreSettings fragment with ProjectSettings instead
List of administrators who receive error notifications. Django equivalent: ADMINS = [(‘name’, ‘email’), …]
managers: Vec<Contact>use CoreSettings fragment with ProjectSettings instead
List of managers who receive broken link notifications, etc. Django equivalent: MANAGERS = [(‘name’, ‘email’), …]
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn new(base_dir: PathBuf, secret_key: String) -> Settings
Available on crate feature core only.
pub fn new(base_dir: PathBuf, secret_key: String) -> Settings
core only.Create a new Settings instance with default values
§Examples
use reinhardt_conf::settings::Settings;
use std::path::PathBuf;
#[allow(deprecated)]
let settings = Settings::new(
PathBuf::from("/app"),
"my-secret-key-12345".to_string()
);
assert_eq!(settings.core.base_dir, PathBuf::from("/app"));
assert_eq!(settings.core.secret_key, "my-secret-key-12345");
assert!(settings.core.debug);
assert_eq!(settings.time_zone, "UTC");
assert!(settings.core.installed_apps.is_empty());Sourcepub fn add_app(&mut self, app: impl Into<String>)
👎Deprecated since 0.2.0: Use installed_apps! macro with ApplicationBuilder instead
Available on crate feature core only.
pub fn add_app(&mut self, app: impl Into<String>)
Use installed_apps! macro with ApplicationBuilder instead
core only.Add an installed app
Deprecated since 0.2.0: Use installed_apps! macro with ApplicationBuilder instead.
§Examples
use reinhardt_conf::settings::Settings;
#[allow(deprecated)]
let mut settings = Settings::default();
#[allow(deprecated)]
{
let initial_count = settings.core.installed_apps.len();
settings.add_app("myapp");
assert_eq!(settings.core.installed_apps.len(), initial_count + 1);
assert!(settings.core.installed_apps.contains(&"myapp".to_string()));
}Sourcepub fn with_validated_apps<F>(self, app_provider: F) -> Settings
👎Deprecated since 0.2.0: Use installed_apps! macro with ApplicationBuilder instead
Available on crate feature core only.
pub fn with_validated_apps<F>(self, app_provider: F) -> Settings
Use installed_apps! macro with ApplicationBuilder instead
core only.Create settings with a compile-time validated app list
This method accepts a function that returns Vec<String> generated by the
installed_apps! macro, providing compile-time validation of app names.
Deprecated since 0.2.0: Use installed_apps! macro with ApplicationBuilder instead.
§Examples
use reinhardt_conf::settings::Settings;
#[allow(deprecated)]
let settings = Settings::default()
.with_validated_apps(|| vec![
"reinhardt.contrib.admin".to_string(),
"myapp".to_string(),
]);
#[allow(deprecated)]
{
assert_eq!(settings.core.installed_apps.len(), 2);
assert!(settings.core.installed_apps.contains(&"myapp".to_string()));
}Sourcepub fn add_admin(&mut self, name: impl Into<String>, email: impl Into<String>)
Available on crate feature core only.
pub fn add_admin(&mut self, name: impl Into<String>, email: impl Into<String>)
core only.Add an administrator
§Examples
use reinhardt_conf::settings::{Settings, Contact};
#[allow(deprecated)]
let mut settings = Settings::default();
settings.add_admin("John Doe", "john@example.com");
assert_eq!(settings.admins.len(), 1);
assert_eq!(settings.admins[0].name, "John Doe");
assert_eq!(settings.admins[0].email, "john@example.com");Sourcepub fn add_manager(&mut self, name: impl Into<String>, email: impl Into<String>)
Available on crate feature core only.
pub fn add_manager(&mut self, name: impl Into<String>, email: impl Into<String>)
core only.Add a manager
§Examples
use reinhardt_conf::settings::{Settings, Contact};
#[allow(deprecated)]
let mut settings = Settings::default();
settings.add_manager("Jane Smith", "jane@example.com");
assert_eq!(settings.managers.len(), 1);
assert_eq!(settings.managers[0].name, "Jane Smith");
assert_eq!(settings.managers[0].email, "jane@example.com");Sourcepub fn managers_from_admins(&mut self)
Available on crate feature core only.
pub fn managers_from_admins(&mut self)
core only.Set managers to be the same as administrators
This is a common pattern in Django projects where MANAGERS = ADMINS
§Examples
use reinhardt_conf::settings::Settings;
#[allow(deprecated)]
let mut settings = Settings::default();
settings.add_admin("John Doe", "john@example.com");
settings.add_admin("Jane Smith", "jane@example.com");
settings.managers_from_admins();
assert_eq!(settings.managers.len(), 2);
assert_eq!(settings.managers, settings.admins);Sourcepub fn with_admins(self, admins: Vec<Contact>) -> Settings
Available on crate feature core only.
pub fn with_admins(self, admins: Vec<Contact>) -> Settings
core only.Set administrators with a fluent API
§Examples
use reinhardt_conf::settings::{Settings, Contact};
#[allow(deprecated)]
let settings = Settings::default()
.with_admins(vec![
Contact::new("John Doe", "john@example.com"),
Contact::new("Jane Smith", "jane@example.com"),
]);
assert_eq!(settings.admins.len(), 2);Sourcepub fn with_managers(self, managers: Vec<Contact>) -> Settings
Available on crate feature core only.
pub fn with_managers(self, managers: Vec<Contact>) -> Settings
core only.Set managers with a fluent API
§Examples
use reinhardt_conf::settings::{Settings, Contact};
#[allow(deprecated)]
let settings = Settings::default()
.with_managers(vec![
Contact::new("Alice Brown", "alice@example.com"),
]);
assert_eq!(settings.managers.len(), 1);Sourcepub fn get_static_config(&self) -> Result<StaticFilesConfig, String>
Available on crate feature core only.
pub fn get_static_config(&self) -> Result<StaticFilesConfig, String>
core only.Convert Settings to StaticFilesConfig
This method extracts static files related configuration from Settings
and creates a StaticFilesConfig instance suitable for use with CollectStaticCommand.
§Returns
Returns Ok(StaticFilesConfig) if static_root is configured,
or Err if static_root is None.
§Examples
use reinhardt_conf::settings::Settings;
use std::path::PathBuf;
#[allow(deprecated)]
let settings = Settings::new(
PathBuf::from("/app"),
"secret".to_string()
);
let config = settings.get_static_config().unwrap();
assert_eq!(config.static_url, "/static/");Trait Implementations§
Source§impl<'de> Deserialize<'de> for Settings
impl<'de> Deserialize<'de> for Settings
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Settings, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Settings, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<&Settings> for SecurityConfig
impl From<&Settings> for SecurityConfig
Source§fn from(settings: &Settings) -> SecurityConfig
fn from(settings: &Settings) -> SecurityConfig
Source§impl HasSettings<CoreSettings> for Settings
impl HasSettings<CoreSettings> for Settings
Source§fn get_settings(&self) -> &CoreSettings
fn get_settings(&self) -> &CoreSettings
Source§impl Serialize for Settings
impl Serialize for Settings
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> HasCoreSettings for Twhere
T: HasSettings<CoreSettings>,
impl<T> HasCoreSettings for Twhere
T: HasSettings<CoreSettings>,
Source§fn core(&self) -> &CoreSettings
fn core(&self) -> &CoreSettings
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
Source§fn should_contain_message(&self, expected: &str)where
E: Display,
fn should_contain_message(&self, expected: &str)where
E: Display,
Source§fn should_have_message(&self, expected: &str)where
E: Display,
fn should_have_message(&self, expected: &str)where
E: Display,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.