Feature flag system for enabling/disabling functionality per organization
| Tier | foundation |
| Role | unclassified (baselined) |
| Path | crates/foundation/modules |
| Edition | 2021 |
| Targets | foundation_modules |
| Public items | 37 across 0 modules |
| Tests | 30 |
What it is for
Feature flag system for enabling/disabling functionality per organization.
This crate provides:
Module- Defines a feature/module that can be enabled/disabledOrgModuleState- Tracks module state per organizationModuleStatus- Enabled, Disabled, Trial states
Capabilities
Module
Feature flag system for enabling/disabling functionality per organization.
| Item |
|---|
pub struct Module |
Module :: fn new(slug : impl Into <String>, name : impl Into <String>) -> Self |
Module :: fn with_description(mut self, description : impl Into <String>) -> Self |
Module :: fn as_core(mut self) -> Self |
Module :: fn with_trial_days(mut self, days : i32) -> Self |
Module :: fn with_dependency(mut self, slug : impl Into <String>) -> Self |
Module :: fn deactivate(& mut self) |
Module :: fn activate(& mut self) |
Module :: fn id(& self) -> Uuid |
Module :: fn created_at(& self) -> DateTime <Utc> |
Module :: fn updated_at(& self) -> DateTime <Utc> |
Module :: fn deleted_at(& self) -> Option <DateTime <Utc>> |
ModuleError
Feature flag system for enabling/disabling functionality per organization.
| Item |
|---|
pub enum ModuleError |
ModuleRegistry
Feature flag system for enabling/disabling functionality per organization.
| Item |
|---|
pub struct ModuleRegistry |
ModuleRegistry :: fn new() -> Self |
ModuleRegistry :: fn register(& mut self, module : Module) |
ModuleRegistry :: fn get(& self, slug : & str) -> Option <& Module> |
ModuleRegistry :: fn active_modules(& self) -> Vec <& Module> |
ModuleRegistry :: fn core_modules(& self) -> Vec <& Module> |
ModuleRegistry :: fn check_dependencies(& self, slug : & str, enabled_slugs : & & str) -> bool |
ModuleStatus
Feature flag system for enabling/disabling functionality per organization.
| Item |
|---|
pub enum ModuleStatus |
ModuleStatus :: fn is_accessible(& self) -> bool |
ModuleStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
ModuleStatus :: fn from_str(s : & str) -> std::result::Result <Self, Self::Err> |
OrgModuleState
Feature flag system for enabling/disabling functionality per organization.
| Item |
|---|
pub struct OrgModuleState |
OrgModuleState :: fn new(organization_id : Uuid, module_id : Uuid) -> Self |
OrgModuleState :: fn enable(& mut self) -> Result <()> |
OrgModuleState :: fn disable(& mut self) -> Result <()> |
OrgModuleState :: fn start_trial(& mut self, days : i32) |
OrgModuleState :: fn is_accessible(& self) -> bool |
OrgModuleState :: fn is_trial_valid(& self) -> bool |
OrgModuleState :: fn trial_days_remaining(& self) -> Option <i64> |
OrgModuleState :: fn set_config(& mut self, config : serde_json::Value) |
OrgModuleState :: fn id(& self) -> Uuid |
OrgModuleState :: fn created_at(& self) -> DateTime <Utc> |
OrgModuleState :: fn updated_at(& self) -> DateTime <Utc> |
Result
Feature flag system for enabling/disabling functionality per organization.
| Item |
|---|
pub type Result<T>: std::result::Result <T, ModuleError> |
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`
| Item | What it is |
|---|---|
pub enum ModuleError | Errors that can occur in module operations. |
pub type Result<T>: std::result::Result <T, ModuleError> | Result type for module operations. |
pub enum ModuleStatus | Status of a module for an organization. |
ModuleStatus :: fn is_accessible(& self) -> bool | Returns true if the module is accessible (enabled or in valid trial). |
ModuleStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
ModuleStatus :: fn from_str(s : & str) -> std::result::Result <Self, Self::Err> | — |
pub struct Module | A feature module that can be enabled/disabled per organization. |
Module :: fn new(slug : impl Into <String>, name : impl Into <String>) -> Self | Creates a new module. |
Module :: fn with_description(mut self, description : impl Into <String>) -> Self | Sets the description. |
Module :: fn as_core(mut self) -> Self | Marks as a core module. |
Module :: fn with_trial_days(mut self, days : i32) -> Self | Sets trial duration in days. |
Module :: fn with_dependency(mut self, slug : impl Into <String>) -> Self | Adds a dependency. |
Module :: fn deactivate(& mut self) | Deactivates the module. |
Module :: fn activate(& mut self) | Activates the module. |
Module :: fn id(& self) -> Uuid | — |
Module :: fn created_at(& self) -> DateTime <Utc> | — |
Module :: fn updated_at(& self) -> DateTime <Utc> | — |
Module :: fn deleted_at(& self) -> Option <DateTime <Utc>> | — |
pub struct OrgModuleState | Module state for a specific organization. |
OrgModuleState :: fn new(organization_id : Uuid, module_id : Uuid) -> Self | Creates a new organization module state. |
OrgModuleState :: fn enable(& mut self) -> Result <()> | Enables the module |
OrgModuleState :: fn disable(& mut self) -> Result <()> | Disables the module |
OrgModuleState :: fn start_trial(& mut self, days : i32) | Starts a trial period. |
OrgModuleState :: fn is_accessible(& self) -> bool | Checks if the module is accessible. |
OrgModuleState :: fn is_trial_valid(& self) -> bool | Checks if trial is still valid. |
OrgModuleState :: fn trial_days_remaining(& self) -> Option <i64> | Returns days remaining in trial. |
OrgModuleState :: fn set_config(& mut self, config : serde_json::Value) | Sets custom configuration. |
OrgModuleState :: fn id(& self) -> Uuid | — |
OrgModuleState :: fn created_at(& self) -> DateTime <Utc> | — |
OrgModuleState :: fn updated_at(& self) -> DateTime <Utc> | — |
pub struct ModuleRegistry | A registry for managing modules. |
ModuleRegistry :: fn new() -> Self | Creates a new empty registry. |
ModuleRegistry :: fn register(& mut self, module : Module) | Registers a module. |
ModuleRegistry :: fn get(& self, slug : & str) -> Option <& Module> | Gets a module by slug. |
ModuleRegistry :: fn active_modules(& self) -> Vec <& Module> | Gets all active modules. |
ModuleRegistry :: fn core_modules(& self) -> Vec <& Module> | Gets all core modules. |
ModuleRegistry :: fn check_dependencies(& self, slug : & str, enabled_slugs : & & str) -> bool | Checks if all dependencies for a module are satisfied. |
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) |
| Location | crates/foundation/modules |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-basemodels` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio-test | ^0.4 | — | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_feature_flags["application-feature-flags"] -->|uses| SELF SELF["foundation-modules"] SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | foundation_modules | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
ModuleError | Result |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none 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.
Related capabilities
1 workspace crate depends on this one: application-feature-flags.
Verification
| Kind | Count |
|---|---|
| Unit tests | 30 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 6 | 0 | 1 |
What the tests establish, by name:
test_module_activate_deactivate—src/lib.rstest_module_as_core—src/lib.rstest_module_has_id—src/lib.rstest_module_new—src/lib.rstest_module_serialization—src/lib.rstest_module_soft_deletable—src/lib.rstest_module_status_display—src/lib.rstest_module_status_from_str—src/lib.rstest_module_status_is_accessible—src/lib.rstest_module_with_dependency—src/lib.rstest_module_with_description—src/lib.rstest_module_with_trial_days—src/lib.rstest_org_module_state_disable—src/lib.rstest_org_module_state_disable_already_disabled—src/lib.rstest_org_module_state_enable—src/lib.rstest_org_module_state_enable_already_enabled—src/lib.rstest_org_module_state_new—src/lib.rstest_org_module_state_not_accessible_when_disabled—src/lib.rstest_org_module_state_serialization—src/lib.rstest_org_module_state_set_config—src/lib.rstest_org_module_state_start_trial—src/lib.rstest_org_module_state_trial_days_remaining—src/lib.rstest_registry_check_dependencies_module_not_found—src/lib.rstest_registry_check_dependencies_not_satisfied—src/lib.rstest_registry_check_dependencies_satisfied—src/lib.rstest_registry_core_modules—src/lib.rstest_registry_get—src/lib.rstest_registry_get_not_found—src/lib.rstest_registry_new—src/lib.rstest_registry_register—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 28 | 37 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 28
"No rustdoc detected" : 9
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 688 |
| Code lines | 507 |
| Public API items | 37 |
| Public modules | 0 |
| Tests | 30 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 6 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"enum" : 2
"method" : 31
"struct" : 3
"type alias" : 1
pie showData
title Rust source composition
"Code" : 507
"Blank or comment" : 181
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.