Skip to main content

phi_ext/
lib.rs

1//! Rust author SDK for [Phi] PXB extensions — a faithful port of the Go SDK
2//! under `ext/go`.
3//!
4//! Two layers, mirroring the Go module:
5//!
6//! - [`pxb`]: the binary wire protocol (frames, tagged fields, message codecs)
7//! - [`phi`]: the author-facing API ([`phi::Extension`]) that speaks PXB over
8//!   stdin/stdout
9//!
10//! The crate is dependency-free on purpose: the wire format needs no JSON and
11//! no reflection, so hand-rolled codecs keep the SDK lean.
12//!
13//! # Example
14//!
15//! ```no_run
16//! use phi_ext::{phi, pxb};
17//!
18//! fn main() -> Result<(), phi::Error> {
19//!     let mut m = phi::Extension::new("hello", "0.1.0");
20//!     m.register_command(
21//!         "hello",
22//!         phi::Command::new("Say hi", |_args, ctx| {
23//!             ctx.notify("info", "Hello!");
24//!             Ok(())
25//!         }),
26//!     );
27//!     m.subscribe(pxb::Event::SessionStart, |_ev| {});
28//!     m.run()
29//! }
30//! ```
31//!
32//! [Phi]: https://github.com/pulseaiclub/phi
33
34pub mod phi;
35pub mod pxb;