项目作者: gregwebs

项目描述 :
Use a process as an iterator
高级语言: Rust
项目地址: git://github.com/gregwebs/rust-process-iterator.git
创建时间: 2017-03-05T05:47:50Z
项目社区:https://github.com/gregwebs/rust-process-iterator

开源协议:MIT License

下载


rust-process-iterator

Stream data through an external process.
The stdlib interfaces to running commands and those from other packages do not readily support streaming.
This package fills the gap.

This package supplies 2 functions:

  • process_read_consumer
  • process_as_reader

process_read_consumer takes a Read as stdin and waits for the process to finish.
process_as_reader gives back a Read of stdout

One difficult aspect of streaming is error handling. process_as_reader additionally gives back a future to check for errors

Things in this package should look somewhat familiar to the Child data type that is getting wrapped.
Of notable addition is the Output type, in particular Output::ToFd which directs the command builder to direct output directly to a given file (which must have a valid descriptor).

Please look at the test suite
for more example usage.

Development

You can encapsulate development of this library in a docker container.
There is a ./bin/cargo script for invoking cargo in a container with the working directory
mounted.