ryo-source
Status: stable. Part of the ryo workspace — AST-centric Rust programming for AI agents.
High-speed Rust AST manipulation engine. Provides two complementary AST
representations: RustAST for full-fidelity manipulation (preserves
spans, supports code generation) and PureFile for thread-safe parallel
processing (span-free, Send + Sync + Arc-shareable, serializable).
Install
Optional features:
| Feature | Effect |
|---|---|
parallel |
Enables rayon-backed parallel transforms |
serde |
Derives Serialize / Deserialize on PureFile and friends |
schemars |
JSON Schema generation for PureFile |
test-utils |
Test helpers (tempfile workspace) |
Quickstart
Remove unused imports with RustAST:
use RustAST;
let mut ast = parse.unwrap;
let removed = ast.remove_unused_imports;
assert_eq!;
assert!;
Share an AST across threads with PureFile:
use Arc;
use thread;
use PureFile;
let pure = from_source.unwrap;
let shared = new;
let s1 = clone;
let handle = spawn;
assert_eq!;
API Summary
| Type | Purpose |
|---|---|
RustAST |
Full-fidelity AST wrapping syn::File — spans preserved, code-gen capable, not Send + Sync |
PureFile |
Span-stripped AST — Send + Sync, Arc-shareable, serializable, ~10% size of RustAST |
PureItem / PureFn / PureStruct / PureImpl / … |
Owned variants of syn items used by PureFile |
pure::* |
Pure pattern, expression, statement, attribute, generics types |
See the crate docs for the full module index.
Status
- API surface is considered stable for the v0.1.0 release.
RustASTis for in-process editing only; cross-thread workflows should usePureFile.
License
Licensed under either of Apache-2.0 or MIT at your option.