foundation tier

foundation-layers

Layer boundary enforcement for architectural constraints

Layer boundary enforcement for architectural constraints

Tierfoundation
Roleunclassified (baselined)
Pathcrates/foundation/layers
Edition2021
Targetsfoundation_layers
Public items20 across 0 modules
Tests26

What it is for

Layer boundary enforcement for architectural constraints.

This crate provides types and traits for enforcing architectural layers at compile time and runtime. It helps maintain clean separation between:

Capabilities

crate root

Layer boundary enforcement for architectural constraints.

Item
fn validate_dependencies(source : Layer, dependencies : & Dependency) -> Result <()>

Component

Layer boundary enforcement for architectural constraints.

Item
pub struct Component
Component :: fn new(name : impl Into <String>, layer : Layer) -> Self
Component :: fn with_dependency(mut self, dep : Dependency) -> Self
Component :: fn validate(& self) -> Result <()>

Dependency

Layer boundary enforcement for architectural constraints.

Item
pub struct Dependency
Dependency :: fn new(name : impl Into <String>, layer : Layer, path : impl Into <String>) -> Self

Layer

Layer boundary enforcement for architectural constraints.

Item
pub enum Layer
Layer :: const fn level(& self) -> u8
Layer :: const fn can_depend_on(& self, target : Layer) -> bool
Layer :: fn validate_dependency(& self, target : Layer) -> Result <()>
Layer :: const fn name(& self) -> & 'static str
Layer :: const fn description(& self) -> & 'static str
Layer :: const fn all() -> Layer; 5
Layer :: fn allowed_dependencies(& self) -> Vec <Layer>
Layer :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
Layer :: fn from_str(s : & str) -> Result <Self>

LayerError

Layer boundary enforcement for architectural constraints.

Item
pub enum LayerError

Layered

Layer boundary enforcement for architectural constraints.

Item
pub trait Layered

Result

Layer boundary enforcement for architectural constraints.

Item
pub type Result<T>: std::result::Result <T, LayerError>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub enum LayerErrorErrors that can occur with layer violations.
pub type Result<T>: std::result::Result <T, LayerError>Result type for layer operations.
pub enum LayerArchitectural layer in the application.
Layer :: const fn level(& self) -> u8Returns the numeric level of the layer.
Layer :: const fn can_depend_on(& self, target : Layer) -> boolReturns true if this layer can depend on the target layer
Layer :: fn validate_dependency(& self, target : Layer) -> Result <()>Validates that this layer can depend on the target layer
Layer :: const fn name(& self) -> & 'static strReturns the layer name.
Layer :: const fn description(& self) -> & 'static strReturns a description of what belongs in this layer.
Layer :: const fn all() -> Layer; 5Returns all layers.
Layer :: fn allowed_dependencies(& self) -> Vec <Layer>Returns layers that this layer can depend on.
Layer :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result
Layer :: fn from_str(s : & str) -> Result <Self>
pub trait LayeredTrait for types that belong to a specific layer.
pub struct DependencyA dependency declaration with layer information.
Dependency :: fn new(name : impl Into <String>, layer : Layer, path : impl Into <String>) -> SelfCreates a new dependency.
fn validate_dependencies(source : Layer, dependencies : & Dependency) -> Result <()>Validates a list of dependencies against a source layer
pub struct ComponentA component with layer information.
Component :: fn new(name : impl Into <String>, layer : Layer) -> SelfCreates a new component.
Component :: fn with_dependency(mut self, dep : Dependency) -> SelfAdds a dependency.
Component :: fn validate(& self) -> Result <()>Validates all dependencies

No pub use re-exports: every item above is declared in this crate.

Boundary

Depends on no other workspace tier.

Shares tier foundation with 27 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (27 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)foundation
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/foundation/layers
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
serde^1derivenoalways
thiserror^2noalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
serde_json^1noalways
tokio-test^0.4noalways

Build. None.

Depended on by. Nothing in this workspace.

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libfoundation_layers`src/lib.rs`

Error model

Error typeNamed by
LayerErrorResult

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

No workspace crate depends on this one.

Verification

KindCount
Unit tests26
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root700

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1820
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 18
    "No rustdoc detected" : 2

Metrics

MetricValue
Rust source files1
Source lines497
Code lines356
Public API items20
Public modules0
Tests26
Examples0
Cargo features0
Direct runtime dependencies2
Workspace reverse dependencies0
pie showData
    title Public API by kind
    "enum" : 2
    "function" : 1
    "method" : 13
    "struct" : 2
    "trait" : 1
    "type alias" : 1
pie showData
    title Rust source composition
    "Code" : 356
    "Blank or comment" : 141

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All foundation · Manual