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):
- Introduce
shared_types(this file) with stable serde + schemars (schema) derivations. - Add
pub mod shared_types;tolib.rs(future patch). - Add
From/Intoimpls in calling code rather than here to avoid introducing circular compilation dependencies while both legacy type sets still exist. - Gradually replace internal uses:
- Prefer
shared_types::SourceLocationetc. - Remove duplicated structs from
doc_engine::typesandindex_core::typesonce references are gone.
- Prefer
- 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).
visibilitykept asString(enum later when rustdoc variants fully enumerated).kindalso left asStringfor forward compatibility.- Optional fields kept as
Option<T>; empty vectors preferVec<T>notOption<Vec<T>>to simplify consumer logic. - Added
#[non_exhaustive]where future evolution is likely.
Future Enhancements:
- Introduce strongly typed enums for
ItemKind,Visibility,SymbolKindwithserde(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§
- Impl
Item - Individual member (method / assoc item) inside an implementation block.
- ItemDoc
- Documentation & analysis metadata for a single symbol / item.
- Search
Index Data - Crate‑scoped search index dataset (one version).
- Search
Index Item - Lightweight search index item (mirrors docs.rs structure).
- Semantic
Search Result - Semantic search result for language-aware discovery (Python, etc.).
- Source
Location - Canonical source span reference inside a file.
- Source
Snippet - Code snippet with context.
- Symbol
Search Result - Symbol search result (post‑query scoring).
- Trait
Impl - Trait implementation (impl
for ). - Type
Impl - Implemented trait entry when listing traits for a type.
Enums§
- Shared
Type Error - Unified error domain stub (future: centralize).
Traits§
- TryFrom
Shared - Helper trait for converting from shared canonical forms. (Symmetric with TryIntoShared for clearer intent.)
- TryInto
Shared - 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.