pub struct PTYSession {
pub id: String,
pub slot_id: String,
pub cwd: PathBuf,
pub cols: u16,
pub rows: u16,
/* private fields */
}Expand description
Interactive PTY session for Claude Code
Manages a single Claude Code process with terminal emulation, state detection, and streaming text extraction.
Fields§
§id: StringUnique session ID
slot_id: StringSlot ID this session belongs to
cwd: PathBufWorking directory
cols: u16Terminal dimensions
rows: u16Implementations§
Source§impl PTYSession
impl PTYSession
Sourcepub fn new(options: PTYSessionOptions) -> Result<Self>
pub fn new(options: PTYSessionOptions) -> Result<Self>
Create a new PTY session
Sourcepub async fn state(&self) -> SessionState
pub async fn state(&self) -> SessionState
Get current state
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if session is running
Sourcepub async fn pending_tool_confirm(&self) -> Option<ConfirmInfo>
pub async fn pending_tool_confirm(&self) -> Option<ConfirmInfo>
Get pending tool confirmation
Sourcepub async fn terminal_title(&self) -> String
pub async fn terminal_title(&self) -> String
Get terminal title
Sourcepub async fn get_screen_text(&self) -> String
pub async fn get_screen_text(&self) -> String
Get current screen text
Sourcepub async fn get_last_lines(&self, n: usize) -> Vec<String>
pub async fn get_last_lines(&self, n: usize) -> Vec<String>
Get last N lines
Sourcepub async fn send(&self, message: &str, timeout_ms: u64) -> Result<String>
pub async fn send(&self, message: &str, timeout_ms: u64) -> Result<String>
Send message and wait for response
Sourcepub async fn confirm(&self, response: ConfirmResponse) -> Result<()>
pub async fn confirm(&self, response: ConfirmResponse) -> Result<()>
Send confirmation response
Sourcepub async fn set_permission_check<F>(&self, callback: F)
pub async fn set_permission_check<F>(&self, callback: F)
Set permission check callback
Sourcepub fn subscribe(&self) -> Receiver<SessionEvent>
pub fn subscribe(&self) -> Receiver<SessionEvent>
Subscribe to session events
Sourcepub fn subscribe_state_changes(&self) -> Receiver<(SessionState, SessionState)>
pub fn subscribe_state_changes(&self) -> Receiver<(SessionState, SessionState)>
Subscribe to state changes
Sourcepub async fn wait_for_state(
&self,
target: SessionState,
timeout_duration: Duration,
) -> Result<()>
pub async fn wait_for_state( &self, target: SessionState, timeout_duration: Duration, ) -> Result<()>
Wait for specific state
Auto Trait Implementations§
impl !RefUnwindSafe for PTYSession
impl !UnwindSafe for PTYSession
impl Freeze for PTYSession
impl Send for PTYSession
impl Sync for PTYSession
impl Unpin for PTYSession
impl UnsafeUnpin for PTYSession
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.