Generic preferences storage with scope/namespace/key design
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/preferences |
| Edition | 2021 |
| Targets | infrastructure_preferences |
| Public items | 0 across 0 modules |
| Tests | 8 |
What it is for
infrastructure-preferences: Generic preferences storage
Overview
This crate provides a preferences storage system with scope/namespace/key design. Preferences are stored in Postgres with JSONB values for flexibility.
Key Types
PreferenceScope- Who owns the preference (user, tenant, org)PreferenceKey- Fully qualified preference keyPreferencesService- Get/set/delete operations
Example
use infrastructure_preferences::{PreferenceKey, PreferencesService};
let service = PreferencesService::new(pool);
let key = PreferenceKey::user(user_id, "support-web", "theme");
// Set a preference
service.set(&key, &"dark").await?;
// Get a preference
let theme: Option<String> = service.get(&key).await?;
// Get with default
let theme: String = service.get_or_default(&key).await?;
Capabilities
No public items.
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
No public items.
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
PreferencesService | service::PreferencesService |
{PreferenceKey,PreferenceScope} | models::{PreferenceKey,PreferenceScope} |
{PreferencesError,PreferencesResult} | error::{PreferencesError,PreferencesResult} |
Boundary
Depends on no other workspace tier.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 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) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/preferences |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | 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 | ^1 | full, rt-multi-thread, macros | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_preferences["application-preferences"] -->|uses| SELF SELF["infrastructure-preferences"] 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 | infrastructure_preferences | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | yes |
| 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-preferences.
Verification
| Kind | Count |
|---|---|
| Unit tests | 8 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
What the tests establish, by name:
test_preference_key_accepts_string_types—src/lib.rstest_preference_key_tenant_scope—src/lib.rstest_preference_key_user_scope—src/lib.rstest_preference_scope_from_str_invalid—src/lib.rstest_preference_scope_from_str_tenant—src/lib.rstest_preference_scope_from_str_user—src/lib.rstest_preference_scope_tenant_as_str—src/lib.rstest_preference_scope_user_as_str—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 4 |
| Source lines | 328 |
| Code lines | 202 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 8 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 7 |
| Workspace reverse dependencies | 1 |
pie showData
title Rust source composition
"Code" : 202
"Blank or comment" : 126
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.