pub struct SessionId(/* private fields */);Expand description
Unique identifier for a Claude Code session.
Wraps a UUID string (e.g., “8e11bfb5-7dc2-432b-9206-928fa5c35731”).
Obtained from Claude Code’s status line JSON session_id field.
Implementations§
Source§impl SessionId
impl SessionId
Sourcepub fn new(id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>) -> Self
Creates a new SessionId from a string.
Note: This does not validate UUID format. Claude Code provides the session_id, so we trust its format.
Sourcepub fn pending_from_pid(pid: u32) -> Self
pub fn pending_from_pid(pid: u32) -> Self
Creates a pending session ID from a process ID.
Used when a Claude process is discovered but no transcript exists yet (e.g., session just started, no conversation has occurred). The pending session will be upgraded to the real session ID when it arrives via hook event or status line.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Checks if this is a pending session ID (not yet associated with real session).
Sourcepub fn pending_pid(&self) -> Option<u32>
pub fn pending_pid(&self) -> Option<u32>
Extracts the PID from a pending session ID.
Returns None if this is not a pending session ID or the PID cannot be parsed.