Skip to main content

Module shared_types

Module shared_types 

Source
Expand description

Shared canonical type definitions for Dociium.

Motivation: The project originally duplicated many structurally identical data structures across doc_engine::types and index_core::types, e.g.:

  • SourceLocation
  • ItemDoc
  • ImplItem / TraitImpl / TypeImpl
  • SymbolSearchResult
  • SearchIndexItem / SearchIndexData
  • SourceSnippet

This module introduces canonical representations intended to be the single source of truth. Other modules can (incrementally) migrate to these definitions, minimizing maintenance burden and serialization / schema drift.

Integration Plan (incremental, low‑risk):

  1. Introduce shared_types (this file) with stable serde + schemars (schema) derivations.
  2. Add pub mod shared_types; to lib.rs (future patch).
  3. Add From / Into impls in calling code rather than here to avoid introducing circular compilation dependencies while both legacy type sets still exist.
  4. Gradually replace internal uses:
    • Prefer shared_types::SourceLocation etc.
    • Remove duplicated structs from doc_engine::types and index_core::types once references are gone.
  5. Expose via MCP schemas directly from this module for consistency.

Design Notes:

  • Field names retain the most widely used naming style to keep JSON stable (backwards compatibility).
  • visibility kept as String (enum later when rustdoc variants fully enumerated).
  • kind also left as String for forward compatibility.
  • Optional fields kept as Option<T>; empty vectors prefer Vec<T> not Option<Vec<T>> to simplify consumer logic.
  • Added #[non_exhaustive] where future evolution is likely.

Future Enhancements:

  • Introduce strongly typed enums for ItemKind, Visibility, SymbolKind with serde(other) fallbacks.
  • Attach rich lifetime / generics info to impls when upstream extraction improves.

This file is intentionally dead_code‑tolerant during migration.

SPDX-License-Identifier: MIT OR Apache-2.0

Structs§

ImplItem
Individual member (method / assoc item) inside an implementation block.
ItemDoc
Documentation & analysis metadata for a single symbol / item.
SearchIndexData
Crate‑scoped search index dataset (one version).
SearchIndexItem
Lightweight search index item (mirrors docs.rs structure).
SemanticSearchResult
Semantic search result for language-aware discovery (Python, etc.).
SourceLocation
Canonical source span reference inside a file.
SourceSnippet
Code snippet with context.
SymbolSearchResult
Symbol search result (post‑query scoring).
TraitImpl
Trait implementation (impl for ).
TypeImpl
Implemented trait entry when listing traits for a type.

Enums§

SharedTypeError
Unified error domain stub (future: centralize).

Traits§

TryFromShared
Helper trait for converting from shared canonical forms. (Symmetric with TryIntoShared for clearer intent.)
TryIntoShared
Helper trait for fallible conversion into shared canonical types.

Functions§

backfill_doc_summary
Utility: shallow merge of doc summaries where the canonical result is missing. Returns updated target reference.
map_vec_try_into
Utility: map a collection with TryIntoShared.

Type Aliases§

SharedResult