Skip to main content

PtySession

Struct PtySession 

Source
pub struct PtySession { /* private fields */ }
Expand description

A live PTY-managed child plus its output drainer. The owner (a worker process under Outcome B) holds this for the child’s lifetime.

Implementations§

Source§

impl PtySession

Source

pub fn spawn( cmd: CommandBuilder, rows: u16, cols: u16, ring_bytes: usize, ) -> Result<PtySession, PtyError>

Spawn cmd on a fresh PTY of rowsxcols with an output ring of ring_bytes, and start the drainer thread.

Source

pub fn drain_outcome(&self) -> DrainOutcome

Why the drainer stopped (or DrainOutcome::Running if still draining). The daemon turns an Errored outcome into a pty_drainer_errored event.

Source

pub fn child_pid(&self) -> Option<u32>

PID of the spawned child, if the platform reported one.

Source

pub fn write_input(&self, bytes: &[u8]) -> Result<(), PtyError>

Write bytes to the child’s stdin (PTY master). The caller is responsible for any envelope wrapping (non-Claude providers).

Source

pub fn resize(&self, rows: u16, cols: u16) -> Result<(), PtyError>

Resize the PTY (drive resize handshake, terminal change).

Source

pub fn snapshot(&self) -> Vec<u8>

Snapshot the current ring contents (oldest-to-newest).

Source

pub fn dropped_bytes(&self) -> u64

Bytes dropped from the ring due to overflow.

Source

pub fn read_since(&self, cursor: u64) -> ReadSince

Incrementally read PTY output appended after cursor (drive streaming). See BoundedRing::read_since. A poisoned ring recovers in place rather than propagating a panic onto the drive output pump.

Source

pub fn is_child_alive(&self) -> bool

True if the child has not yet exited.

On a poisoned child mutex this returns true (assume alive), NOT false: the primary consumer is Drop, which kills the child only when this reports alive. Reporting false on poison would skip the kill and leak a still-running child. Erring toward “alive” makes Drop attempt the (idempotent) kill instead.

Source

pub fn wait(&self) -> Result<u32, PtyError>

Block until the child exits, returning its exit code (if known).

Source

pub fn kill(&self) -> Result<(), PtyError>

Kill the child (SIGKILL-equivalent via portable-pty).

Trait Implementations§

Source§

impl Drop for PtySession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more