pub struct Config {Show 16 fields
pub root: PathBuf,
pub source: Option<PathBuf>,
pub app: AppConfig,
pub api: ApiConfig,
pub server: ServerConfig,
pub build: BuildConfig,
pub assets: AssetsConfig,
pub rendering: RenderingConfig,
pub images: ImagesConfig,
pub security: SecurityConfig,
pub env: EnvConfig,
pub dev: DevConfig,
pub logging: LoggingConfig,
pub redirects: Vec<RedirectRule>,
pub headers: Vec<HeaderRule>,
pub plugins: BTreeMap<String, Value>,
}Fields§
§root: PathBufProject root (directory containing the config file). Not read from the file.
source: Option<PathBuf>The config file that was loaded, if any.
app: AppConfig§api: ApiConfig§server: ServerConfig§build: BuildConfig§assets: AssetsConfig§rendering: RenderingConfig§images: ImagesConfig§security: SecurityConfig§env: EnvConfig§dev: DevConfig§logging: LoggingConfig§redirects: Vec<RedirectRule>§headers: Vec<HeaderRule>§plugins: BTreeMap<String, Value>Free-form plugin configuration: [plugins.my-plugin].
Implementations§
Source§impl Config
impl Config
Sourcepub fn discover(start: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn discover(start: impl AsRef<Path>) -> Result<Self, ConfigError>
Discover and load the configuration starting at start.
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Self, ConfigError>
pub fn load(path: impl AsRef<Path>) -> Result<Self, ConfigError>
Load a specific file (.toml or .json).
pub fn from_toml_str(text: &str) -> Result<Self, String>
pub fn from_json_str(text: &str) -> Result<Self, String>
Sourcepub fn apply_env_overrides(&mut self)
pub fn apply_env_overrides(&mut self)
PORT and HOST (conventional on container platforms) override the file.
Sourcepub fn resolve(&self, path: impl AsRef<Path>) -> PathBuf
pub fn resolve(&self, path: impl AsRef<Path>) -> PathBuf
Resolve a path from the configuration against the project root.
pub fn app_dir(&self) -> PathBuf
pub fn public_dir(&self) -> PathBuf
pub fn api_dir(&self) -> Option<PathBuf>
pub fn output_dir(&self) -> PathBuf
Sourcepub fn validate(&self) -> Vec<Diagnostic>
pub fn validate(&self) -> Vec<Diagnostic>
Validate paths and values; returns human friendly diagnostics.
pub fn socket_addr_string(&self) -> String
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
Mutably borrows from an owned value. Read more