How metamolecular/trey works
Project type and purpose
• This is a Rust library/crate (“Trey”) whose sole purpose is to provide primitives for reading and writing V3000 CTfile formats (chemical connection‐table files). It is not a client/server or full-stack app but an open-source toolkit/library for parsing and serializing chemoinformatics file formats.
File structure
• Top‐level artifacts:
• Cargo.toml, rustfmt.toml, .cargo/config.toml – Cargo build and formatting configuration
• src/lib.rs – the public API entry point
• src/header/… – modules for parsing and representing the CTfile header block
• src/ctab/… – modules for representing and parsing the connection table (atoms, bonds, R-groups, etc.)
• src/write/… – modules for serializing header and connection table back into V3000 CTfile syntax
• There are no frontend/backend or network layers; instead the architecture is organized as three main Rust sub-crates (namespaced modules) under one library:
header ←─ ctab ─→ write
README for additional insights
• Confirms focus on V3000 CTfile read/write primitives
• Points to an external article for design rationale
• Mentions only a test suite (no external services or deployment artifacts)
a. Main components
• Public API (lib.rs): exposes functions like read_ctfile and write_ctfile.
• Header module (src/header): parses and models the file header (metadata, version codes, scaling factors, timestamps).
• Connection-table module (src/ctab): data structures and parsers for atoms, bonds, R-groups, coordinates, implicit hydrogens, valences.
• Write module (src/write): takes in-memory Header + CT structures and emits V3000-compliant text blocks.
• Test Suite (cargo test): verifies parsing and serialization correctness.
b. Relationships and interactions
• The Public API depends on both header and ctab modules to build a complete in-memory representation.
• The write module depends on the same in-memory structures to serialize them back to disk.
• Error types propagate upward (header::error and ctab::error aggregated in public API).
c. Architectural patterns/design principles
• Modular decomposition by file format concerns (separate header vs. body).
• Clear separation of parsing vs. serialization logic.
• Strongly-typed domain model in Rust (enums for element kinds, bond configurations, etc.).
• Single library crate, no microservices—just internal modules.
d. Key technologies, frameworks, libraries
• Rust language and Cargo build system
• No external dependencies (pure Rust, no FFI)
• Rust’s error handling (Result, custom error enums)
• Rust fmt and lint tooling (rustfmt.toml)
Emphasize
• How errors bubble up (error.rs in header and ctab).