2026-04-24 12:32:24 -06:00
|
|
|
//! UnShell core protocol crate.
|
|
|
|
|
//!
|
|
|
|
|
//! The crate now models the draft protocol in `PROTOCOL.md` directly:
|
|
|
|
|
//!
|
|
|
|
|
//! - [`protocol`] provides the canonical wire types, framing helpers, validation,
|
|
|
|
|
//! and introspection payloads.
|
|
|
|
|
//! - [`tree`] provides an explicit enum-based tree declaration, longest-prefix
|
|
|
|
|
//! routing helpers, and a small endpoint runtime for tests.
|
|
|
|
|
//! - [`transport`] provides framed transport implementations for simulated
|
|
|
|
|
//! channel-based links and TCP links.
|
|
|
|
|
//! - [`logger`] remains available for lightweight logging.
|
|
|
|
|
//!
|
|
|
|
|
//! ```rust
|
|
|
|
|
//! use unshell::protocol::{CallMessage, HookTarget, PacketHeader, PacketType, encode_packet};
|
|
|
|
|
//!
|
|
|
|
|
//! let header = PacketHeader {
|
|
|
|
|
//! packet_type: PacketType::Call,
|
|
|
|
|
//! src_path: Vec::new(),
|
|
|
|
|
//! dst_path: vec!["child".into()],
|
|
|
|
|
//! dst_leaf: Some("echo".into()),
|
|
|
|
|
//! hook_id: None,
|
|
|
|
|
//! };
|
|
|
|
|
//! let call = CallMessage {
|
|
|
|
|
//! procedure_id: "org.product.v1.echo.roundtrip".into(),
|
|
|
|
|
//! data: b"ping".to_vec(),
|
|
|
|
|
//! response_hook: Some(HookTarget {
|
|
|
|
|
//! hook_id: 1,
|
|
|
|
|
//! return_path: Vec::new(),
|
|
|
|
|
//! }),
|
|
|
|
|
//! };
|
|
|
|
|
//!
|
|
|
|
|
//! let frame = encode_packet(&header, &call).expect("call should encode");
|
|
|
|
|
//! assert!(!frame.is_empty());
|
2026-04-20 23:38:02 -06:00
|
|
|
//! ```
|
2026-03-17 16:40:05 -06:00
|
|
|
|
2026-04-24 12:32:24 -06:00
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
2026-03-17 16:40:05 -06:00
|
|
|
extern crate alloc;
|
2025-11-08 14:56:03 -07:00
|
|
|
|
2025-11-09 12:34:52 -07:00
|
|
|
pub mod logger;
|
2026-04-20 23:38:02 -06:00
|
|
|
pub mod protocol;
|
|
|
|
|
pub mod transport;
|
2026-02-09 10:27:15 -07:00
|
|
|
pub mod tree;
|
2025-11-08 14:56:03 -07:00
|
|
|
|
2026-02-09 10:27:15 -07:00
|
|
|
pub use ush_obfuscate as obfuscate;
|