Skip to main content

Crate tokmd_core

Crate tokmd_core 

Source
Expand description

§tokmd-core

Tier 4 (Library Facade)

This crate is the primary library interface for tokmd. It coordinates scanning, aggregation, and modeling to produce code inventory receipts.

If you are embedding tokmd into another Rust application, depend on this crate and tokmd-types. Avoid depending on tokmd-scan or tokmd-model directly unless necessary.

§What belongs here

  • High-level workflow coordination
  • Simplified API for library consumers
  • Re-exports for convenience
  • FFI-friendly JSON entrypoint

§What does NOT belong here

  • CLI argument parsing (use tokmd crate)
  • Low-level scanning logic (use tokmd-scan)
  • Aggregation details (use tokmd-model)

§Example

use tokmd_core::{lang_workflow, settings::{ScanSettings, LangSettings}};

// Configure scan
let scan = ScanSettings::current_dir();
let lang = LangSettings {
    top: 10,
    files: true,
    ..Default::default()
};

// Run pipeline
let receipt = lang_workflow(&scan, &lang).expect("Scan failed");
assert!(receipt.report.rows.len() > 0);

§JSON API (for bindings)

use tokmd_core::ffi::run_json;

let result = run_json("lang", r#"{"paths": ["."], "top": 10}"#);
let parsed: serde_json::Value = serde_json::from_str(&result).unwrap();
assert_eq!(parsed["ok"], true);

Re-exports§

pub use tokmd_types as types;

Modules§

context_git
Lightweight git scoring for context ranking.
context_policy
Deterministic context/handoff policy helpers.
error
Structured error types for binding-friendly API.
ffi
FFI-friendly JSON entrypoint coordinator for language bindings.
settings
Pure settings types for binding-friendly API.

Structs§

InMemoryFile
A single logical file supplied from memory rather than the host filesystem.
TimedWorkflow
A normal workflow receipt plus opt-in timing evidence.
WorkflowTiming
Timing evidence for one core workflow run.

Constants§

CORE_SCHEMA_VERSION
Re-export schema version for bindings.

Functions§

diff_workflow
Runs the diff workflow comparing two receipts or paths.
export_workflow
Runs the export workflow with pure settings types.
export_workflow_from_inputs
Runs the file export workflow for ordered in-memory inputs.
lang_workflow
Runs the language summary workflow with pure settings types.
lang_workflow_from_inputs
Runs the language summary workflow for ordered in-memory inputs.
module_workflow
Runs the module summary workflow with pure settings types.
module_workflow_from_inputs
Runs the module summary workflow for ordered in-memory inputs.
timed_export_workflow
Runs the export workflow and records scan/model/receipt phase timings.
timed_lang_workflow
Runs the language workflow and records scan/model/receipt phase timings.
timed_module_workflow
Runs the module workflow and records scan/model/receipt phase timings.
version
Get the current tokmd version.