Skip to main content

Module content_dispatch

Module content_dispatch 

Source
Expand description

Content trait dispatch — render any ValueWord value as a ContentNode.

The render_as_content function implements the Content trait dispatch logic:

  1. If the value IS already a ContentNode → return as-is
  2. Match by NanTag/HeapValue type → built-in Content impls for primitives
  3. Fallback → Display as ContentNode::plain(display_string)

Built-in Content implementations:

  • string → ContentNode::plain(self)
  • number/int/decimal → ContentNode::plain(formatted)
  • bool → ContentNode::plain(“true”/“false”)
  • Vec → ContentNode::Table with columns from schema fields
  • Vec → ContentNode::plain(“[1, 2, 3]”)
  • HashMap<K,V> → ContentNode::KeyValue
  • TypedObject → ContentNode::KeyValue with field names from schema

§ContentFor

The render_as_content_for function adds adapter-aware dispatch:

  1. ContentFor → adapter-specific rendering
  2. Content → generic content rendering
  3. Display fallback → plain text

Adapter types: Terminal, Html, Markdown, Json, Plain

Modules§

adapters
Well-known adapter names for ContentFor dispatch.

Functions§

capabilities_for_adapter
Create a RendererCapabilities descriptor for a given adapter name.
datatable_to_content_node
Convert a DataTable (Arrow RecordBatch wrapper) to a ContentNode::Table.
render_as_content
Render a ValueWord value as a ContentNode using Content dispatch.
render_as_content_for
set_user_content_for_resolver
Register a user-defined ContentFor resolver.
set_user_content_resolver
Register a user-defined Content trait resolver.

Type Aliases§

UserContentForResolver
Render a ValueWord value as a ContentNode with adapter-specific dispatch.
UserContentResolver
Optional user-defined Content impl resolver.