pylon_functions/lib.rs
1//! TypeScript function runtime for pylon.
2//!
3//! This crate provides the Rust side of the bidirectional protocol between
4//! the pylon runtime (Rust) and user-defined TypeScript functions (Bun/Deno).
5//!
6//! # Architecture
7//!
8//! ```text
9//! Client ──► Rust Runtime ──► FunctionRunner ──► Bun Process
10//! │ │
11//! │ 1. Acquire lock (mutations) │
12//! │ 2. Send {call, fn, args, auth} │
13//! │ 3. Receive {db, op, ...} ◄────┘
14//! │ 4. Execute SQL, return result ────►│
15//! │ 5. Receive {stream, data} ◄────┘
16//! │ 6. Forward SSE to client │
17//! │ 7. Receive {return, value} ◄────┘
18//! │ 8. COMMIT or ROLLBACK │
19//! └─────────────────────────────────────-┘
20//! ```
21//!
22//! # Function types
23//!
24//! - **Query**: read-only, uses read pool, concurrent execution
25//! - **Mutation**: read+write, transactional, handler IS the transaction
26//! - **Action**: external I/O allowed, non-transactional, calls queries/mutations
27
28pub mod protocol;
29pub mod registry;
30pub mod runner;
31pub mod trace;