Expand description
The seam of the switchback-rs toolchain.
switchback-traits owns the trait spine and the in-memory model that every
parser and every renderer depends on. See the workspace
Glossary
for terminology.
Protocol vs contract family: contract family describes spec grammar
(OpenAPI, Protobuf, AsyncAPI); protocol
describes invocation and transport semantics (http, grpc, custom). Entity
and contract nodes carry ProtocolAttachment lists populated by family
parsers and decoded by switchback-protocols.
Structured HTTP method/path and gRPC streaming facts live in attachments, not
in OperationBody::signature alone.
§Traits
ContractFamilyandContract— parser-side identity and loaded viewsProtocolAttachment— transport envelope on contract and entity nodesRenderer/SyncRenderer— target-format rendering (async primary)SwitchbackCodec/SyncSwitchbackCodec— binary switchback I/OLinkExtractor/AsyncLinkExtractor— intra-link extractionLinkFormatter— resolved link string formattingCompanionStrategy/AsyncCompanionStrategy— companion discovery
I/O traits follow ADR 0002:
async-primary with sync-secondary APIs for external compatibility. All seam
types must traverse async task boundaries (Send / Sync as appropriate).
Helper implementations (slug, link check, paths, companion discovery, prose
escaping) are partially centralized; companion nav metadata and ancestor
discovery live in companion. Remaining helpers deferred.
Structs§
- Anchor
- Byte span within a prose field (
doc,fence_body, etc.). - Channel
Body - Channel entity body (async messaging endpoint).
- Companion
- Companion document embedded in the switchback.
- Companion
File - Parser-side companion file discovered beside contract inputs.
- Contract
Ref - Address of a contract within a manual.
- Document
- A single input document carried verbatim in the switchback source layer.
- Entity
- Parser-side entity with a family-typed category.
- Entity
Id - Entity address within a manual: group + category + name.
- Entity
Ref - Address of an entity within a manual.
- Extension
Body - Opaque family-specific extension entity body.
- External
Url - External URL link target (not resolved to an in-manual entity).
- Group
- Intra-contract grouping unit (package, tag group, application, etc.).
- GroupId
- Intra-contract grouping identifier (protobuf package, OpenAPI tag, etc.).
- Group
Ref - Address of a group within a manual.
- Indexed
Entity - Flat index entry for one entity in a resolved manual.
- Intra
Link - Prose-level link with anchor, resolved target, and raw author text.
- Layout
Entity Key - Layout entity key for path indexing (protobuf package + kind + name).
- Link
Context - Entity output path index used by
LinkFormatter. - Manual
Contract - Serialized contract within a
ReferenceManual. - Manual
Ref - Cross-manual reference by URI with optional inner target.
- Message
Body - Message entity body (payload type excerpt).
- Module
- A cohesive documentation unit that may span contract families.
- Module
Id - Top-level module identifier within a reference manual.
- Module
Ref - Address of a module within a manual.
- Operation
Body - Operation entity body (RPC signature, parameters, responses).
- Operation
Request Body Ref - Request body attachment on an
OperationBody. - Options
- Spine options shared across renderers (subset ported from protobuf-mdbook).
- Output
File - One rendered output file (path relative to book root unless absolute).
- Parameter
Body - Parameter entity body (location, requirement, schema excerpt).
- Parameter
Ref - Parameter attachment on an
OperationBody, referencing a schema entity. - Property
- One property on a schema-like entity, pointing at another entity via
Reference. - Protocol
Attachment - Opaque protocol binding stored on contract and entity IR nodes.
- RawDoc
- Raw document bytes before full parse, used for version detection.
- Reference
- Structural cross-reference in an entity body (schema
$ref, protobuf FQN, etc.). - Reference
Manual - Top-level switchback artifact every parser emits and every renderer reads.
- Request
Body Body - Request body entity (requirement flag and schema excerpt).
- Resolved
Manual - Whole-manual address space used by
LinkExtractor. - Response
Body - Response entity body (status, media type, schema excerpt).
- Response
Ref - Response attachment on an
OperationBody, referencing a schema entity. - Schema
Body - Schema entity body (type definition with optional properties).
- Security
Scheme Body - Security scheme entity body.
- Service
Body - Service definition entity body.
- Source
- Pointer into a
Documentby URI plus optional span. - Source
Ref - Stable provenance for a raw input document.
- Span
- Byte span within a source document (1-based line/column coordinates).
- Spec
Version - Contract-family spec version string (e.g.
"3.1.1","2.6.0"). - Stored
Entity - One entity as stored in a serialized switchback
Group. - Supported
Version - One supported spec version entry in a family’s version matrix.
Enums§
- Companion
Discovery - Where a family searches for companion documents relative to contract inputs.
- Entity
Body - Discriminated entity payload mirroring the proto
oneof body. - Escape
Tags - How to rewrite HTML-like tags in leading-comment prose.
- Generic
Category - Categories renderers know how to format specially.
- Layout
- Page layout for generated markdown.
- Link
Target - Resolved intra-link destination.
- Manual
RefInner - Inner target of a
ManualRefcross-manual link. - Open
ApiOperation Source - How to render the raw OpenAPI operation YAML/JSON on operation pages.
- Open
ApiSummary Label - How to label OpenAPI operations in SUMMARY and package index links.
- Protobuf
Entity Kind - Protobuf entity kind for layout path indexing.
- RefKind
- Classification of a structural reference in source.
- Response
Severity - Cross-family outcome severity for a response or RPC result.
- Switchback
Error - Error type for seam operations (codec, render, load, link extraction).
- Version
Status - Lifecycle status of a supported contract spec version.
Traits§
- Async
Companion Strategy - Async companion fetch (remote registries, URL-backed docs).
- Async
Contract Loader - Async loading of remote or multi-document contracts (I/O primary API).
- Async
Link Extractor - Extract intra-links with async cross-manual or remote resolution.
- Companion
Strategy - How a family discovers, names, and places companion docs (sync, local).
- Contract
- A loaded, resolved contract ready to render or serialize.
- Contract
Family - Identity and capability metadata for one contract family.
- Entity
Category - Typed entity category owned by each contract family.
- Link
Extractor - Extract intra-links from entity prose (sync, in-memory resolution).
- Link
Formatter - Format a resolved link target for one output format (sync, no I/O).
- Renderer
- Async renderer for service-side and streaming pipelines.
- Switchback
Codec - Async codec for I/O-backed serialize/deserialize of
ReferenceManualartifacts. - Sync
Renderer - Synchronous compatibility API for callers that cannot wrap
Renderer. - Sync
Switchback Codec - Synchronous compatibility API for callers that cannot wrap
SwitchbackCodec.
Functions§
- anchor
- Builds an anchor for a byte span within a named field.
- apply_
intra_ links - Applies resolved intra-links to a prose field, replacing anchored spans with formatted link strings.
- companion_
files_ to_ stored - Convert parser-side companions into stored switchback companions.
- companion_
output_ name_ from_ path - Dot-separated output filename from a relative directory path and stem.
- companion_
output_ name_ from_ segments - Dot-separated output filename for a companion under
source_dirsegments. - decode_
markdown_ link_ path - Decode a percent-encoded Markdown link path back to a filesystem path.
- discover_
ancestors_ companions - Discover companion markdown by walking ancestor directories from each anchor.
- encode_
markdown_ link_ path - Percent-encode a relative path for use inside Markdown
](...)link targets. - entity_
category_ dir - Relative output directory segment for a stored entity category slug.
- entity_
rel_ path - Relative output path for an entity page under a group’s markdown tree.
- heading_
slug - Heading anchor id compatible with mdBook HTML output.
- layout_
entity_ rel_ path - Relative entity page path for entity/split layouts.
- links_
for_ field - Returns intra-links whose anchor targets
field. - module_
path_ from_ output - Dot-separated module path implied by a companion output filename.
- normalize_
rel_ dir - Normalize a relative directory path to normal components only.
- package_
index_ rel - Relative path to a package index page (entity/split layouts).
- package_
page_ rel - Relative path to a package rollup page under
markdown_root. - relative_
path_ from_ dir - Relative POSIX path from
from_dirtotarget(mdBook link form). - source_
dir_ from_ output - Inverse of dot-encoded output name for legacy artifacts missing
source_dir. - source_
dir_ string - Slash-separated source directory string for wire nav metadata.
- title_
from_ markdown - Title from the first
#heading in markdown, else humanized stem. - unique_
heading_ ids - Assigns mdBook-style unique heading ids in document order (appends
-1,-2, … on collision).
Type Aliases§
- Result
- Result alias for seam operations that surface
SwitchbackError.