Crate assemblage_view[][src]

Expand description

Linearized view of AssemblageDB nodes.

Nodes in an AssemblageDB form a directed, possibly cylic graph and cannot be straightforwardly displayed without first “linearizing” them into a view that shows only a single subtree and renders all connected parents or siblings as links that branch off. This crate provides such a frontend-independent view model, which can be used as a high level, linearized interface to an AssemblageDB by frontends on different platforms.

A linearized view consists of 6 different levels of components:

  • A single Space, which contains one or more tiles (usually arranged horizontally side by side).
  • Tiles, a single node and its subtree (of descendants), which can contain zero or more sections.
  • Sections, a single editable subsections or an uneditable group of subsections that appear as children of multiple nodes.
  • Subsections, which contain a single block and one or more branches leading to other nodes before or after the block.
  • Blocks, descendants of the top-level node that must be displayed as blocks due to their layout or style.
  • Spans, the descendants of the block descendants that must be displayed as spans due to their layout or style.

The following is an example of 3 different tiles arranged in a space:

Tile 1:                     Tile 2:                     Tile 3:
+---------------------+     +---------------------+     +---------------------+
| Section 1:          |     | Section 1:          |     | Section 1:          |
| +-----------------+ |     | +-----------------+ |     | +-----------------+ |
| | Subsection 1:   | |     | | Subsection 1:   | |     | | Subsection 1:   | |
| | Before:         | |     | | Block:          | |     | | Block:          | |
| | +-------------+ | |     | | +-------------+ | |     | | +-------------+ | |
| | | Branch 1    | | |     | | | Span 1:     | | |     | | | Span 1:     | | |
| | +-------------+ | |     | | | +---------+ | | |     | | | +---------+ | | |
| | Block:          | |     | | | | Link    | | | |     | | | | "Text"  | | | |
| | +-------------+ | |     | | | +---------+ | | |     | | | +---------+ | | |
| | | Span 1:     | | |     | | | Span 2:     | | |     | | +-------------+ | |
| | | +---------+ | | |     | | | +---------+ | | |     | | After:          | |
| | | | "Text"  | | | |     | | | | Link    | | | |     | | +-------------+ | |
| | | +---------+ | | |     | | | +---------+ | | |     | | | Branch      | | |
| | | Span 2:     | | |     | | +-------------+ | |     | | +-------------+ | |
| | | +---------+ | | |     | | Subsection 2:   | |     | +-----------------+ |
| | | | Link    | | | |     | | Block:          | |     | Section 2:          |
| | | +---------+ | | |     | | +-------------+ | |     | +-----------------+ |
| | +-------------+ | |     | | | Span 1:     | | |     | | Subsection 1:   | |
| +-----------------+ |     | | | +---------+ | | |     | | Block:          | |
+---------------------+     | | | | "Text"  | | | |     | | +-------------+ | |
                            | | | +---------+ | | |     | | | Span 1:     | | |
                            | | +-------------+ | |     | | | +---------+ | | |
                            | +-----------------+ |     | | | | "Text"  | | | |
                            +---------------------+     | | | +---------+ | | |
                                                        | | +-------------+ | |
                                                        | +-----------------+ |
                                                        +---------------------+

While subtrees of AssemblageDB nodes are defined recursively and can be arbitrarily deep, the nesting of a view is fixed:

  • Spaces can only contain tiles, never other spaces.
  • Tiles can only contain sections, never other tiles.
  • Sections can only contain subsections, never other sections.
  • A subsection awlays contains a single block, never other subsections.
  • Blocks can only contain spans, never other blocks.
  • Spans can only contain immediate content, never other spans.

As a result, frontends only have to follow a very simple document model, which is always just 6 levels deep: A space contains tiles, which contain sections, which contain subsections, which contain a single block, which contain spans.

By design, nested lists (as in Markdown) or multiple levels of headings are not supported. Instead of a single, complex and hierarchical document, Assemblage spaces favor a collection of relatively flat tiles. The richer structure of an Assemblage space emerges as the result of the interplay of these intertwined nodes.

A space contains all the data necessary for displaying the currently viewed node without the need to read from the DB again. DB access is necessary only for dynamic UIs once the user navigates to another node.

Modules

Query and update functions for a wasm frontend backed by an AssemblageDB.

A minimal markup language for Assemblage text blocks.

Components that form an AssemblageDB view.

Macros

Creates a BTreeSet, useful for creating an ordered set of styles.

Enums

The error type for view operations.

Traits

A linearized view of a DB that can display nodes in terms of a tile of sections with subsections, spans and branches to other nodes. Acts as a “view layer” and transforms the graph of nodes into a linearized representation suitable for a human-readable UI.

Type Definitions

A specialized Result type for view operations.