Struct expectrl::Session[][src]

pub struct Session { /* fields omitted */ }
Expand description

Session represents a process and its streams. It controlls process and communication with it.

Implementations

Spawn spawn a cmd process

Spawn spawns a command

Expect waits until a pattern is matched.

It return error if expect_timeout is reached.

Set the pty session’s expect timeout.

Methods from Deref<Target = PtyProcess>

Returns a pid of a child process

Returns a file representation of a PTY, which can be used to communicate with it.

use ptyprocess::PtyProcess;
use std::{process::Command, io::{BufReader, LineWriter}};

let mut process = PtyProcess::spawn(Command::new("cat")).unwrap();
let pty = process.get_pty_handle().unwrap();
let mut writer = LineWriter::new(&pty);
let mut reader = BufReader::new(&pty);

Get window size of a terminal.

Default is size is 80x24.

Sets a terminal size

Waits until a echo settings were setup

Get_echo returns true if an echo setting is setup.

Sets a echo setting for a terminal

Set the pty process’s terminate approach delay.

Status returns a status a of child process.

Kill sends a signal to a child process.

The operation is non-blocking.

Signal is an alias to kill.

Wait blocks until a child process exits.

It returns a error if the child was DEAD or not exist at the time of a call. So sometimes it’s better to use a is_alive method

Checks if a process is still exists.

It’s a non blocking operation. It’s takes in mind errors which indicates that the child is gone.

Try to force a child to terminate.

It starts nicely with SIGHUP, SIGCONT, SIGINT, SIGTERM. If “force” is True then moves onto SIGKILL.

This returns true if the child was terminated. and returns false if the child could not be terminated.

Send writes a string to a STDIN of a child.

Send writes a line to a STDIN of a child.

Send controll character to a child process.

Send EOF indicator to a child process.

Send INTR indicator to a child process.

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.