pub struct ExecSession {
pub id: SessionId,
pub command: String,
pub working_dir: String,
pub started_at: Instant,
pub timeout: Option<Duration>,
pub status: SessionStatus,
/* private fields */
}Expand description
A background exec session.
Fields§
§id: SessionIdSession identifier.
command: StringThe command that was executed.
working_dir: StringWorking directory.
started_at: InstantWhen the session started.
timeout: Option<Duration>Timeout duration (if set).
status: SessionStatusCurrent status.
Implementations§
Source§impl ExecSession
impl ExecSession
Sourcepub fn new(
command: String,
working_dir: String,
timeout: Option<Duration>,
child: Child,
) -> Self
pub fn new( command: String, working_dir: String, timeout: Option<Duration>, child: Child, ) -> Self
Create a new session for a running process.
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Check if the process has exceeded its timeout.
Sourcepub fn append_output(&mut self, text: &str)
pub fn append_output(&mut self, text: &str)
Append output to the combined buffer.
Sourcepub fn poll_output(&mut self) -> &str
pub fn poll_output(&mut self) -> &str
Get new output since the last poll.
Sourcepub fn full_output(&self) -> &str
pub fn full_output(&self) -> &str
Get the full output log.
Sourcepub fn log_output(&self, offset: Option<usize>, limit: Option<usize>) -> String
pub fn log_output(&self, offset: Option<usize>, limit: Option<usize>) -> String
Get output with line-based offset and limit.
Sourcepub fn try_read_output(&mut self) -> bool
pub fn try_read_output(&mut self) -> bool
Try to read any available output from the child process. Returns true if any output was read.
Uses platform-specific non-blocking I/O.
Sourcepub fn check_exit(&mut self) -> bool
pub fn check_exit(&mut self) -> bool
Check if the process has exited and update status.
Sourcepub fn write_stdin(&mut self, data: &str) -> Result<(), String>
pub fn write_stdin(&mut self, data: &str) -> Result<(), String>
Write data to the process stdin.
Sourcepub fn send_keys(&mut self, keys: &str) -> Result<usize, String>
pub fn send_keys(&mut self, keys: &str) -> Result<usize, String>
Translate named keys to escape sequences and write them to stdin.
Supports key names: Enter, Tab, Escape, Space, Backspace, Up, Down, Left, Right, Home, End, PageUp, PageDown, Delete, Insert, Ctrl-A..Ctrl-Z, Ctrl-C, F1..F12, and plain text.
Multiple keys can be separated by spaces: "Enter", "Ctrl-C",
"Up Up Down Down Left Right".