foundation tier

foundation-view-mode

How a list of things is laid out: cards, thumbnails or a list. The vocabulary only -- no rendering, no framework, no storage -- so a Leptos component and a server-rendered page cannot disagree about the words.

How a list of things is laid out: cards, thumbnails or a list. The vocabulary only -- no rendering, no framework, no storage -- so a Leptos component and a server-rendered page cannot disagree about the words.

Tierfoundation
Rolevalue_object
Pathcrates/foundation/view-mode
Edition2021
Targetsfoundation_view_mode
Public items6 across 0 modules
Tests6

What it is for

How a list of things is laid out: cards, thumbnails, or a list.

The vocabulary and nothing else. No rendering, no framework, no storage — so that a Leptos component and a server-rendered page can hold the same three words without either owning them.

# Why this exists

ViewToggle was written for rust-inventory-ai, lifted into platform-leptos-components in sprint 10A, and is used by platform-staff-ui, platform-customer-ui and application-leptos-components. It is a Leptos component.

The sightings pages are server-rendered HTML held in Rust string constants and cannot consume it. The obvious move — a second component library with its own ViewMode — puts Cards / Thumbs / List in two places with nothing holding them equal. Renaming a variant in one would break nothing that any test could see, because each library's tests would still pass.

So the words live here, below both, and each track renders them its own way. Change a variant and both fail to compile. That is the mechanism; everything else is convention.

Deliberately absent: load_view_mode and save_view_mode. Those touch browser storage, which is gloo_storage on one track and a line of JavaScript on the other — the one part that genuinely differs, and putting it here would drag a WASM dependency into a crate whose whole purpose is not having one. What is shared is storage_key, the name they agree to store it under.

Capabilities

crate root

How a list of things is laid out: cards, thumbnails, or a list.

Item
fn storage_key(list : & str) -> String

ViewMode

How a list of things is laid out: cards, thumbnails, or a list.

Item
pub enum ViewMode
ViewMode :: fn parse(s : & str) -> Self
ViewMode :: fn as_str(self) -> & 'static str
ViewMode :: fn all() -> Self; 3
ViewMode :: fn label(self) -> & 'static str

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 ViewModeHow a list of things is laid out
ViewMode :: fn parse(s : & str) -> SelfRead a stored or user-supplied value
ViewMode :: fn as_str(self) -> & 'static strThe stored form
ViewMode :: fn all() -> Self; 3Every mode, in the order a switcher should offer them — most detail to least.
ViewMode :: fn label(self) -> & 'static strWhat to call it in a control.
fn storage_key(list : & str) -> StringThe browser-storage key a given list should remember its mode under

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)value_object
Locationcrates/foundation/view-mode
Vocabulary in force (lexicon)current

Dependencies

Runtime. None.

Development. None.

Build. None.

Depended on by. 2 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_platform_html_components["platform-html-components"] -->|uses| SELF
  n_platform_leptos_components["platform-leptos-components"] -->|uses| SELF
  SELF["foundation-view-mode"]
  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

KindNameSource
libfoundation_view_mode`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

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.

2 workspace crates depend on this one: platform-html-components, platform-leptos-components.

Verification

KindCount
Unit tests6
Integration tests0
Examples0
Doctests0

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

ModuleTestsExamplesConsumers
crate root204

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc66
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 6
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files1
Source lines153
Code lines85
Public API items6
Public modules0
Tests6
Examples0
Cargo features0
Direct runtime dependencies0
Workspace reverse dependencies2
pie showData
    title Public API by kind
    "enum" : 1
    "function" : 1
    "method" : 4
pie showData
    title Rust source composition
    "Code" : 85
    "Blank or comment" : 68

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