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.
| Tier | foundation |
| Role | value_object |
| Path | crates/foundation/view-mode |
| Edition | 2021 |
| Targets | foundation_view_mode |
| Public items | 6 across 0 modules |
| Tests | 6 |
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`
| Item | What it is |
|---|---|
pub enum ViewMode | How a list of things is laid out |
ViewMode :: fn parse(s : & str) -> Self | Read a stored or user-supplied value |
ViewMode :: fn as_str(self) -> & 'static str | The stored form |
ViewMode :: fn all() -> Self; 3 | Every mode, in the order a switcher should offer them — most detail to least. |
ViewMode :: fn label(self) -> & 'static str | What to call it in a control. |
fn storage_key(list : & str) -> String | The 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 |
| Location | crates/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
| Kind | Name | Source |
|---|---|---|
| lib | foundation_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
| 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
2 workspace crates depend on this one: platform-html-components, platform-leptos-components.
Verification
| Kind | Count |
|---|---|
| Unit tests | 6 |
| 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 | 2 | 0 | 4 |
What the tests establish, by name:
a_storage_key_is_per_list—src/lib.rsan_unknown_value_is_cards_rather_than_an_error—src/lib.rsevery_mode_is_offered_once_and_labelled—src/lib.rsthe_default_is_cards—src/lib.rsthe_stored_form_round_trips—src/lib.rsthe_stored_strings_are_the_ones_already_written_to_disk—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 6 | 6 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 6
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 153 |
| Code lines | 85 |
| Public API items | 6 |
| Public modules | 0 |
| Tests | 6 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 0 |
| Workspace reverse dependencies | 2 |
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.