stream.bend relies on unsafe/foreign
raw source on the hub · import bend-kit-stream@0.1.0.1/stream.bend as Stream
Bounded packed-byte transfers between files and TCP/TLS sockets.
3 imports
import Base import bend-kit-files@0.1.1.1/files.bend as Files import bend-kit-wire@0.4.6.1/wire.bend as Wire
Types
type Error source · line 6 · raw
Data
BadChunkError
LimitError
Read@code:U32 -> @message:String -> Error
Write@code:U32 -> @message:String -> Error
type Outcome source · line 12 · raw
Data
Complete@count:U32 -> Outcome
Failed@count:U32 -> @error:Error -> Outcome
type ReadAction source · line 17 · raw
Data
Internal pure decisions, separated from the trusted effects.
EndReadAction
OverReadAction
ForwardReadAction
type Transfer source · line 47 · raw
@-S:Type -> @-D:Type -> Type
More@-S:Type -> @-D:Type -> @source:S -> @destination:D -> @count:U32 -> Transfer<S, D>
Stop@-S:Type -> @-D:Type -> @source:S -> @destination:D -> @outcome:Outcome -> Transfer<S, D>
Definitions
def chunk.valid source · line 22 · raw
@+chunk:U32 -> Bool
def request source · line 26 · raw
@+chunk:U32 -> @+remaining:U32 -> U32
The one-byte probe is only requested after the entire cap was forwarded.
def read.action.flags source · line 33 · raw
@zero:Bool -> @probe:Bool -> ReadAction
def read.action source · line 44 · raw
@len:U32 -> @remaining:U32 -> ReadAction
def file.read source · line 51 · raw
@source:File -> @max:U32 -> @tls:Bool -> @ms:U32 -> IO(Pair(File, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))
def file.write source · line 55 · raw
@destination:File -> @len:U32 -> @words:Array<U32> -> @tls:Bool -> IO(Pair(File, Result<&1, &1, Pair(U32, String), Unit>))
def socket.read.tls source · line 59 · raw
@tls:Bool -> @source:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))
def socket.read source · line 67 · raw
@source:Socket -> @max:U32 -> @tls:Bool -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))
def socket.write.tls source · line 71 · raw
@tls:Bool -> @destination:Socket -> @len:U32 -> @words:Array<U32> -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
def socket.write source · line 79 · raw
@destination:Socket -> @len:U32 -> @words:Array<U32> -> @tls:Bool -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
def file.file source · line 159 · raw
@source:File -> @destination:File -> @+chunk:U32 -> @cap:U32 -> IO(Pair(File, Pair(File, Outcome)))
Return both handles on every outcome; never close or retry a failed chunk.
def file.socket source · line 164 · raw
@source:File -> @destination:Socket -> @tls:Bool -> @+chunk:U32 -> @cap:U32 -> IO(Pair(File, Pair(Socket, Outcome)))
def socket.file source · line 170 · raw
@source:Socket -> @destination:File -> @tls:Bool -> @+chunk:U32 -> @cap:U32 -> @ms:U32 -> IO(Pair(Socket, Pair(File, Outcome)))
ms is the unchanged per-read Wire deadline, including the one-byte cap probe.
Templates
template transfer.written source · line 83 · raw
@-S:Type -> @-D:Type -> @source:S -> @count:U32 -> @len:U32 -> @pair:Pair(D, Result<&1, &1, Pair(U32, String), Unit>) -> Transfer<S, D>
template transfer.action source · line 92 · raw
@-S:Type -> @-D:Type -> @-write:(@_:D -> @_:U32 -> @_:Array<U32> -> @_:Bool -> IO(Pair(D, Result<&1, &1, Pair(U32, String), Unit>))) -> @action:ReadAction -> @source:S -> @destination:D -> @count:U32 -> @+len:U32 -> @words:Array<U32> -> @tls:Bool -> IO(Transfer<S, D>)
template transfer.read source · line 106 · raw
@-S:Type -> @-D:Type -> @-write:(@_:D -> @_:U32 -> @_:Array<U32> -> @_:Bool -> IO(Pair(D, Result<&1, &1, Pair(U32, String), Unit>))) -> @pair:Pair(S, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>) -> @destination:D -> @count:U32 -> @remaining:U32 -> @tls:Bool -> IO(Transfer<S, D>)
template transfer.loop source · line 120 · raw
@-S:Type -> @-D:Type -> @-read:(@_:S -> @_:U32 -> @_:Bool -> @_:U32 -> IO(Pair(S, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))) -> @-write:(@_:D -> @_:U32 -> @_:Array<U32> -> @_:Bool -> IO(Pair(D, Result<&1, &1, Pair(U32, String), Unit>))) -> @fuel:Nat -> @state:Transfer<S, D> -> @+tls:Bool -> @+chunk:U32 -> @+cap:U32 -> @+ms:U32 -> IO(Pair(S, Pair(D, Outcome)))
cap+1 reads suffice even if every successful nonempty read contains one byte. Fuel is first among runtime parameters; no fixed read ceiling or unsafe recursion.
template transfer.start source · line 146 · raw
@-S:Type -> @-D:Type -> @-read:(@_:S -> @_:U32 -> @_:Bool -> @_:U32 -> IO(Pair(S, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))) -> @-write:(@_:D -> @_:U32 -> @_:Array<U32> -> @_:Bool -> IO(Pair(D, Result<&1, &1, Pair(U32, String), Unit>))) -> @valid:Bool -> @source:S -> @destination:D -> @tls:Bool -> @chunk:U32 -> @+cap:U32 -> @ms:U32 -> IO(Pair(S, Pair(D, Outcome)))