pub struct Config {
pub items: Vec<ConfigItem>,
pub include_context: Vec<String>,
}Expand description
Root node of a parsed nginx configuration file.
Use directives() for top-level directives only, or
all_directives() to recurse into blocks.
Call to_source() to reconstruct the source text.
Fields§
§items: Vec<ConfigItem>Top-level items (directives, comments, blank lines).
include_context: Vec<String>Context from parent file when this config was included Empty for root file, e.g., [“http”, “server”] for a file included in server block
Implementations§
Source§impl Config
impl Config
pub fn new() -> Self
Sourcepub fn directives(&self) -> impl Iterator<Item = &Directive>
pub fn directives(&self) -> impl Iterator<Item = &Directive>
Returns an iterator over top-level directives (excludes comments and blank lines)
Sourcepub fn all_directives(&self) -> AllDirectives<'_> ⓘ
pub fn all_directives(&self) -> AllDirectives<'_> ⓘ
Returns an iterator over all directives recursively (for lint rules)
Sourcepub fn all_directives_with_context(&self) -> AllDirectivesWithContextIter<'_> ⓘ
pub fn all_directives_with_context(&self) -> AllDirectivesWithContextIter<'_> ⓘ
Returns an iterator over all directives with parent context information.
Each item is a DirectiveWithContext that includes
the parent block stack and nesting depth. The include_context is used as the initial
parent context.
Sourcepub fn is_included_from(&self, context: &str) -> bool
pub fn is_included_from(&self, context: &str) -> bool
Check if this config is included from within a specific context.
Sourcepub fn is_included_from_http(&self) -> bool
pub fn is_included_from_http(&self) -> bool
Check if this config is included from within http context.
Sourcepub fn is_included_from_http_server(&self) -> bool
pub fn is_included_from_http_server(&self) -> bool
Check if this config is included from within http > server context.
Sourcepub fn is_included_from_http_location(&self) -> bool
pub fn is_included_from_http_location(&self) -> bool
Check if this config is included from within http > ... > location context.
Sourcepub fn is_included_from_stream(&self) -> bool
pub fn is_included_from_stream(&self) -> bool
Check if this config is included from within stream context.
Sourcepub fn immediate_parent_context(&self) -> Option<&str>
pub fn immediate_parent_context(&self) -> Option<&str>
Get the immediate parent context (last element in include_context).