[][src]Struct pwner::tokio::Process

pub struct Process(_, _);

An implementation of Process that uses tokio::process as the launcher.

All read and write operations are async.

Note: On *nix platforms, the owned process will have 2 seconds between signals, which is run in a spawned task.

Panics

When, on *nix platforms, a process gets dropped without a runtime.

Implementations

impl Process[src]

pub fn read_from(&mut self, read_source: ReadSource) -> &mut Self[src]

Choose which pipe to read form next.

Examples

Basic usage:

use tokio::io::AsyncReadExt;
use tokio::process::Command;
use pwner::Spawner;
use pwner::tokio::ReadSource;

let mut child = Command::new("ls").spawn_owned().unwrap();
let mut buffer = [0_u8; 1024];

child.read_from(ReadSource::Both).read(&mut buffer).await.unwrap();

pub fn decompose(
    &mut self
) -> (&mut ChildStdin, &mut ChildStdout, &mut ChildStderr)
[src]

Decomposes the handle into mutable references to the pipes.

Examples

Basic usage:

use tokio::io::{ AsyncReadExt, AsyncWriteExt };
use tokio::process::Command;
use pwner::Spawner;

let mut child = Command::new("cat").spawn_owned().unwrap();
let mut buffer = [0_u8; 1024];
let (stdin, stdout, _) = child.decompose();

stdin.write_all(b"hello\n").await.unwrap();
stdout.read(&mut buffer).await.unwrap();

Trait Implementations

impl AsyncRead for Process[src]

impl AsyncWrite for Process[src]

impl Drop for Process[src]

impl Process for Process[src]

#[must_use]fn id(&self) -> Option<u32>[src]

Returns the OS-assigned process identifier associated with this child.

Examples

Basic usage:

use tokio::process::Command;
use pwner::{ Spawner, Process };

let mut command = Command::new("ls");
if let Ok(child) = command.spawn_owned() {
    match child.id() {
      Some(pid) => println!("Child's ID is {}", pid),
      None => println!("Child has already exited"),
    }
} else {
    println!("ls command didn't start");
}

Auto Trait Implementations

impl !RefUnwindSafe for Process

impl Send for Process

impl Sync for Process

impl Unpin for Process

impl !UnwindSafe for Process

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<R> AsyncReadExt for R where
    R: AsyncRead + ?Sized
[src]

impl<W> AsyncWriteExt for W where
    W: AsyncWrite + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.