~/bend-docscommunity

impl.bend relies on unsafe/foreign

raw source on the hub · import bend-pipe-session@0.2.0.0/impl.bend as Impl

Talks in lines to a started program, over pipes, with or without a deadline. Send lines, then read lines until one starts with a given text. It knows no protocol.

2 imports
import Base
import bend-stdio-pipes@0.2.0.0/impl.bend as Stdio

Types

type PipeSession source · line 8 · raw

Type

A running program: its process id, the File that writes its stdin, the File that reads its stdout, and the most bytes in one of its lines, with its line end.

type Heard source · line 12 · raw

Type

A line of the program, as PipeSession.ask sorts it.

Definitions

def PipeSession.pid source · line 18 · raw

@session:PipeSession -> Pair(PipeSession, U32)

def PipeSession.started source · line 23 · raw

@opened:Result<&1, &1, Pair(U32, String), Pair(U32, Pair(File, File))> -> @line_cap:U32 -> Result<&1, &1, Pair(U32, String), PipeSession>

def PipeSession.start source · line 34 · raw

@program:String -> @args:List<&1, String> -> @line_cap:U32 -> IO(Result<&1, &1, Pair(U32, String), PipeSession>)

Starts program with args. A longer line of it fails with E2BIG (7).

def PipeSession.ended source · line 45 · raw

U32

The code of the error that PipeSession.ask gives when the program ended before its answer: EPIPE.

def Heard.read source · line 48 · raw

@read:Pair(File, Result<&1, &1, Pair(U32, String), Maybe<&1, String>>) -> @+until:String -> Pair(File, Heard)

def PipeSession.ask.go source · line 63 · raw

@fuel:Nat -> @at:Pair(File, Heard) -> @+until:String -> @+line_cap:U32 -> @said:List<&2, String> -> IO(Pair(File, Result<&1, &1, Pair(U32, String), List<&2, String>>))

said holds the lines so far, the last first; fuel bounds the lines, far beyond any answer.

def PipeSession.asked source · line 98 · raw

@pid:U32 -> @input:File -> @line_cap:U32 -> @answer:Pair(File, Result<&1, &1, Pair(U32, String), List<&2, String>>) -> IO(Pair(PipeSession, Result<&1, &1, Pair(U32, String), List<&2, String>>))

def PipeSession.wrote source · line 111 · raw

@pid:U32 -> @wrote:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @out:File -> @+line_cap:U32 -> @+until:String -> IO(Pair(PipeSession, Result<&1, &1, Pair(U32, String), List<&2, String>>))

def PipeSession.ask source · line 132 · raw

@session:PipeSession -> @lines:List<&1, String> -> @+until:String -> IO(Pair(PipeSession, Result<&1, &1, Pair(U32, String), List<&2, String>>))

Sends lines, then answers the program's lines up to the first that starts with until.

def PipeSession.kill source · line 144 · raw

@session:PipeSession -> IO(Unit)

Kills the program, whether or not it has ended, and closes its Files.

def PipeSession.Answer source · line 154 · raw

Type

What PipeSession.ask gives.

def PipeSession.ask.late source · line 158 · raw

@late:Maybe<&1, PipeSession.Answer> -> IO(Maybe<&1, PipeSession.Answer>)

The answer that came once the program was killed: its Files close.

def PipeSession.ask.polled source · line 168 · raw

@+pid:U32 -> @+chan:Chan(PipeSession.Answer) -> @polled:Poll<&1, &1, Maybe<&1, PipeSession.Answer>, Unit> -> IO(Maybe<&1, PipeSession.Answer>)

def PipeSession.ask.within source · line 189 · raw

@session:PipeSession -> @lines:List<&1, String> -> @+until:String -> @ms:U32 -> IO(Maybe<&1, PipeSession.Answer>)

As PipeSession.ask, within ms; None when the program has not answered by then: it is killed, and the session is gone. Nothing of it runs on after.

def PipeSession.end.go source · line 210 · raw

@fuel:Nat -> @read:Pair(File, Result<&1, &1, Pair(U32, String), Maybe<&1, String>>) -> @+line_cap:U32 -> @said:List<&2, String> -> IO(Result<&1, &1, Pair(U32, String), List<&2, String>>)

def PipeSession.end source · line 235 · raw

@session:PipeSession -> IO(Result<&1, &1, Pair(U32, String), List<&2, String>>)

Closes the program's stdin, then answers what it said until it ended.