pub struct BoundaryConfig {
pub preset: Option<BoundaryPreset>,
pub zones: Vec<BoundaryZone>,
pub rules: Vec<BoundaryRule>,
}Expand description
Architecture boundary configuration.
Defines zones (directory groupings) and rules (which zones may import from which). Optionally uses a built-in preset as a starting point.
§Examples
use fallow_config::BoundaryConfig;
let json = r#"{
"zones": [
{ "name": "ui", "patterns": ["src/components/**"] },
{ "name": "db", "patterns": ["src/db/**"] }
],
"rules": [
{ "from": "ui", "allow": ["db"] }
]
}"#;
let config: BoundaryConfig = serde_json::from_str(json).unwrap();
assert_eq!(config.zones.len(), 2);
assert_eq!(config.rules.len(), 1);Using a preset:
use fallow_config::BoundaryConfig;
let json = r#"{ "preset": "layered" }"#;
let mut config: BoundaryConfig = serde_json::from_str(json).unwrap();
config.expand("src");
assert_eq!(config.zones.len(), 4);
assert_eq!(config.rules.len(), 4);Fields§
§preset: Option<BoundaryPreset>Built-in architecture preset. When set, expands into default zones and rules.
User-defined zones and rules merge on top: zones with the same name replace
the preset zone; rules with the same from replace the preset rule.
Preset patterns use {rootDir}/{zone}/** where rootDir is auto-detected
from tsconfig.json (falls back to src).
Note: preset patterns are flat (src/<zone>/**). For monorepos with
per-package source directories, define zones explicitly instead.
zones: Vec<BoundaryZone>Named zones mapping directory patterns to architectural layers.
rules: Vec<BoundaryRule>Import rules between zones. A zone with a rule entry can only import from the listed zones (plus itself). A zone without a rule entry is unrestricted.
Implementations§
Source§impl BoundaryConfig
impl BoundaryConfig
Sourcepub fn expand(&mut self, source_root: &str)
pub fn expand(&mut self, source_root: &str)
Expand the preset (if set) into zones and rules, merging user overrides on top.
source_root is the directory prefix for preset zone patterns (e.g., "src").
After expansion, self.preset is cleared and all zones/rules are explicit.
Merge semantics:
- User zones with the same name as a preset zone replace the preset zone entirely.
- User rules with the same
fromas a preset rule replace the preset rule. - User zones/rules with new names add to the preset set.
Sourcepub fn preset_name(&self) -> Option<&str>
pub fn preset_name(&self) -> Option<&str>
Return the preset name if one is configured but not yet expanded.
Sourcepub fn validate_zone_references(&self) -> Vec<(usize, &str)>
pub fn validate_zone_references(&self) -> Vec<(usize, &str)>
Validate that all zone names referenced in rules are defined in zones.
Returns a list of (rule_index, undefined_zone_name) pairs.
Sourcepub fn resolve(&self) -> ResolvedBoundaryConfig
pub fn resolve(&self) -> ResolvedBoundaryConfig
Resolve into compiled form with pre-built glob matchers. Invalid glob patterns are logged and skipped.
Trait Implementations§
Source§impl Clone for BoundaryConfig
impl Clone for BoundaryConfig
Source§fn clone(&self) -> BoundaryConfig
fn clone(&self) -> BoundaryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundaryConfig
impl Debug for BoundaryConfig
Source§impl Default for BoundaryConfig
impl Default for BoundaryConfig
Source§fn default() -> BoundaryConfig
fn default() -> BoundaryConfig
Source§impl<'de> Deserialize<'de> for BoundaryConfig
impl<'de> Deserialize<'de> for BoundaryConfig
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>,
Source§impl JsonSchema for BoundaryConfig
impl JsonSchema for BoundaryConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more