~/bend-docscommunity

impl.bend relies on unsafe/foreign

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

THIS MODULE IS PROJECT-AGNOSTIC. KEEP IT THAT WAY. A started program that we talk to in lines, over pipes: 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.1.0.0/impl.bend as Stdio

Types

type PipeSession source · line 9 · 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 13 · raw

Type

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

Definitions

def PipeSession.pid source · line 19 · raw

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

def PipeSession.started source · line 24 · 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 35 · 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 46 · raw

U32

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

def Heard.read source · line 49 · raw

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

def PipeSession.ask.go source · line 64 · 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 99 · 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 112 · 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 133 · 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.end.go source · line 144 · 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 169 · 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.