From 64e53c8cfe68878101d0fb1b4ae8fa07dd77e113 Mon Sep 17 00:00:00 2001 From: Michael Mikovsky <77305074+Astatin3@users.noreply.github.com> Date: Mon, 1 Jun 2026 11:33:17 -0600 Subject: [PATCH] Remove session init context --- src/protocol/runtime.rs | 7 ++----- src/protocol/session.rs | 35 ++--------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/protocol/runtime.rs b/src/protocol/runtime.rs index 78a319e..15406b7 100644 --- a/src/protocol/runtime.rs +++ b/src/protocol/runtime.rs @@ -4,7 +4,7 @@ use crate::{ interface::{InterfaceEventKind, InterfaceStore, InterfaceTarget}, protocol::{ Endpoint, Packet, PacketQueue, Procedure, ProcedureOut, Session, SessionCtx, SessionEntry, - SessionFamily, SessionInit, SessionInitError, SessionStatus, + SessionFamily, SessionInitError, SessionStatus, }, }; @@ -147,10 +147,7 @@ pub fn dispatch_session( return; }; - let packet_path = packet.path.clone(); - let mut init = SessionInit::new(hook_id, packet_path); - - match S::init(leaf, packet, &mut init) { + match S::init(leaf, packet) { Ok(state) => { family.entries.push(SessionEntry::new(hook_id, path, state)); diff --git a/src/protocol/session.rs b/src/protocol/session.rs index e0e9f22..a6a5941 100644 --- a/src/protocol/session.rs +++ b/src/protocol/session.rs @@ -20,9 +20,8 @@ use crate::interface::SessionView; /// fn init( /// leaf: &mut MyLeafState, /// packet: Packet, -/// ctx: &mut SessionInit, /// ) -> Result { -/// Ok(MySessionState::from_open(leaf, packet, ctx)) +/// Ok(MySessionState::from_open(leaf, packet)) /// } /// /// fn update( @@ -47,7 +46,7 @@ pub trait Session: Sized { /// The generated runtime derives all response routing from hook state. Session /// initialization therefore returns only application state or a protocol-level /// rejection; it never stores or receives a caller reply path. - fn init(leaf: &mut L, packet: Packet, ctx: &mut SessionInit) -> Result; + fn init(leaf: &mut L, packet: Packet) -> Result; /// Advances one active hook session. /// @@ -73,36 +72,6 @@ pub trait Session: Sized { } } -/// Context passed to [`Session::init`]. -/// -/// This carries routing metadata that the generated leaf already knows before the -/// session state exists. Protocols that need source paths should encode them in the -/// packet payload; `packet_path` is the destination path that routed the packet here. -pub struct SessionInit { - hook_id: HookID, - packet_path: Vec, -} - -impl SessionInit { - /// Creates initialization metadata for a delivered packet. - pub fn new(hook_id: HookID, packet_path: Vec) -> Self { - Self { - hook_id, - packet_path, - } - } - - /// Returns the hook id that will identify the new session. - pub fn hook_id(&self) -> HookID { - self.hook_id - } - - /// Returns the destination path from the packet that reached this leaf. - pub fn packet_path(&self) -> &[u32] { - &self.packet_path - } -} - /// Error returned when a packet cannot create a new session. pub enum SessionInitError { /// The packet was intentionally consumed without creating state or sending output.