Skip to main content

ModuleRule

Enum ModuleRule 

Source
#[non_exhaustive]
pub enum ModuleRule { MustNotImport { module: String, }, RestrictImportsTo { allowed: Vec<String>, }, MustNotBeImportedBy { importer: String, }, MustOnlyBeImportedBy { allowed: Vec<String>, }, ConfineExternalCrate { crate_name: String, }, ConfineInlineSymbolPath { prefix: String, ending_with: Option<Vec<String>>, strict: bool, }, }
Expand description

What a module boundary forbids.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

MustNotImport

The governed module must not import this module (or anything beneath it).

Fields

§module: String

The forbidden module path (e.g. "crate::projection").

§

RestrictImportsTo

The governed module may import only these modules (each “or beneath”), plus its own subtree; any other internal import is a violation. An empty allowlist permits only the module’s own subtree.

Fields

§allowed: Vec<String>

The closed allowlist of importable module paths (e.g. ["crate::types"]).

§

MustNotBeImportedBy

The governed (protected) module must not be imported by this module (or anything beneath it) — an inbound encapsulation rule, the mirror of MustNotImport. A module within the protected module’s own subtree is never an importer.

Fields

§importer: String

The forbidden importer module path (e.g. "crate::http").

§

MustOnlyBeImportedBy

The governed (protected) module may be imported only by these importers (each “or beneath”) or by its own subtree; any other module that imports it (or anything beneath it) is a violation — the inbound dual of RestrictImportsTo. An empty allowlist permits only the protected module’s own subtree.

Fields

§allowed: Vec<String>

The closed allowlist of importer module paths (e.g. ["crate::facade"]).

§

ConfineExternalCrate

An external crate may be imported only within the governed module’s own subtree (the permitted subtree, or beneath it); any use <crate_name>::… from a module outside that subtree is a violation. The first module rule that observes external imports — every other rule ignores them. The confined crate is the violation target, so identity stays injective across different confined crates on the same subtree.

Fields

§crate_name: String

The confined external crate name (e.g. "libc").

§

ConfineInlineSymbolPath

Within the governed module’s subtree, forbid inline symbol-path calls resolving under a declared module-path prefix — the inline-symbol-path (layer b) sibling of ConfineExternalCrate, observing calls rather than use imports. The “core reads no ambient clock; time is injected” pattern. The confined prefix is the violation target, so identity stays injective across nested prefixes on the same subtree.

Fields

§prefix: String

The confined module-path prefix (e.g. "std::time").

§ending_with: Option<Vec<String>>

If Some, react only on calls whose terminal segment (leaf-exact) is one of these verbs (e.g. ["now"]); None reacts on every call under the prefix. Adopter-owned: a read reachable only through an undeclared verb is a false negative the adopter accepts by narrowing.

§strict: bool

If true, react on any path under the prefix (mentions included — type annotations, constants, value captures), not only calls. Mutually exclusive with ending_with (both set is a constitution error).

Trait Implementations§

Source§

impl Clone for ModuleRule

Source§

fn clone(&self) -> ModuleRule

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModuleRule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for ModuleRule

Source§

impl PartialEq for ModuleRule

Source§

fn eq(&self, other: &ModuleRule) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ModuleRule

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> Tracked for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Recover &dyn Any (and thus the concrete TypeId) from a trait object.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.