pub enum Event {
Show 17 variants
ToolCall,
ToolResult,
ToolExecStart,
ToolExecEnd,
SessionStart,
SessionShutdown,
SessionBeforeSwitch,
BeforeAgentStart,
AgentStart,
AgentEnd,
TurnStart,
TurnEnd,
UserInput,
TurnStopping,
SessionCompact,
PaneAction,
Unknown(u16),
}Expand description
Lifecycle event codes (compact on the wire; strings only at SDK edges). Append-only: never reuse a code. Unknown codes are ignored by peers that did not Subscribe to them.
Variants§
ToolCall
ToolResult
ToolExecStart
ToolExecEnd
SessionStart
SessionShutdown
SessionBeforeSwitch
BeforeAgentStart
AgentStart
AgentEnd
TurnStart
TurnEnd
UserInput
TurnStopping
SessionCompact
PaneAction
Unknown(u16)
Implementations§
Source§impl Event
impl Event
Sourcepub fn code(self) -> u16
pub fn code(self) -> u16
Examples found in repository?
examples/bench.rs (line 39)
25fn main() {
26 let iters = 2_000_000usize;
27
28 bench("encode+decode Hello (small)", iters, || {
29 let b = pxb::encode_hello(&pxb::Hello {
30 name: "greet".into(),
31 version: "1.0.0".into(),
32 caps: 3,
33 protocol: 1,
34 });
35 std::hint::black_box(pxb::decode_hello(&b).unwrap());
36 });
37
38 let req = pxb::InterceptReq {
39 event: pxb::Event::ToolCall.code(),
40 tool_name: "bash".into(),
41 tool_call_id: "call_01JX9K2M".into(),
42 input: br#"{"command":"ls -la /tmp","cwd":"/workspace"}"#.to_vec(),
43 turn_index: 3,
44 ..Default::default()
45 };
46 let frame = pxb::encode_intercept_req(&req);
47 println!("\nInterceptReq payload: {} bytes", frame.len());
48 bench("encode+decode InterceptReq (tool_call)", iters, || {
49 let b = pxb::encode_intercept_req(&req);
50 let d = pxb::decode_intercept_req(&b).unwrap();
51 std::hint::black_box(d.tool_call_id);
52 });
53
54 let ev = pxb::EventNotify {
55 event: pxb::Event::ToolResult.code(),
56 tool_name: "bash".into(),
57 tool_call_id: "call_01JX9K2M".into(),
58 input: req.input.clone(),
59 turn_index: 3,
60 session_id: "sess_01JX".into(),
61 ..Default::default()
62 };
63 let frame = pxb::encode_event_notify(&ev);
64 println!("EventNotify payload: {} bytes", frame.len());
65 bench("encode+decode EventNotify (tool_result)", iters, || {
66 let b = pxb::encode_event_notify(&ev);
67 let d = pxb::decode_event_notify(&b).unwrap();
68 std::hint::black_box(d.session_id);
69 });
70
71 // In-memory frame read/write: the syscall-free floor for one RPC.
72 bench("write_frame+read_frame (in-memory)", iters / 4, || {
73 let mut buf = Vec::new();
74 pxb::write_frame(&mut buf, pxb::TYPE_INTERCEPT, pxb::FLAG_HAS_ID, 42, &frame).unwrap();
75 let mut cur = std::io::Cursor::new(buf);
76 let f = pxb::read_frame(&mut cur).unwrap();
77 std::hint::black_box(f.body.len());
78 });
79}Sourcepub fn from_name(name: &str) -> Self
pub fn from_name(name: &str) -> Self
Parses a public event name; unknown names yield
Unknown(0) (the “no event” code).
Trait Implementations§
impl Copy for Event
impl Eq for Event
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.