tss-rust

Crates.iotss-rust
lib.rstss-rust
version0.2.2
created_at2025-11-03 13:31:41.233059+00
updated_at2025-11-05 15:29:43.602312+00
descriptionGenerated node type enums and metadata from tree-sitter-rust
homepagehttps://github.com/lmmx/tree-sitter-symbols
repositoryhttps://github.com/lmmx/tss
max_upload_size
id1914628
size53,122
Louis Maddox (lmmx)

documentation

https://docs.rs/tss-rust/

README

tss-rust

crates.io documentation MIT licensed

Generated node type enums and metadata from tree-sitter-rust.

Usage

[dependencies]
tss-rust = "0.1"
tree-sitter = "0.24"
tree-sitter-rust = "0.24"
use tree_sitter_symbols_rust::NodeType;
use std::str::FromStr;

let node_type = NodeType::from_str("function_item")?;
assert_eq!(node_type, NodeType::FunctionItem);
assert_eq!(node_type.to_string(), "function_item");

Features

Default includes all metadata:

tss-rust = "0.1"

Select specific metadata:

tss-rust = { version = "0.1", default-features = false, features = ["meta_named", "meta_fields"] }

Available metadata features:

  • meta_named - whether nodes are named in the grammar
  • meta_subtypes - possible subtypes for each node
  • meta_fields - named fields nodes can have
  • meta_children - anonymous children nodes can have
  • meta_extra - extra node markers
  • meta_root - root node markers

How It Works

At build time, each language reads the corresponding tree-sitter-* language crate's NODE_TYPES constant and generates:

  • A NodeType enum with all 280 node types
  • FromStr for parsing node type strings
  • Display for converting back to strings
  • Documentation linking to language reference (best effort, not comprehensive)

This allows a crate to ship this information as an enum type with zero runtime dependencies. All generation happens at compile time. This is useful for type safety (rather than checking for strings, as well as hopefully to demystify how tree-sitter languages work.

Licensing

MIT licensed - see LICENSE for details.

Commit count: 0

cargo fmt