def transfer.start
bend-kit-stream@0.3.1.0 · stream.bend:146
import bend-kit-stream@0.3.1.0/stream.bend as Stream
import Base
146def transfer.start(~S: Type, ~D: Type,
147 ~read: S -> U32 -> Bool -> U32 -> IO(S & Result<&1, &1, U32 & String, U32 & Array<U32>>),
148 ~write: D -> U32 -> Array<U32> -> Bool -> IO(D & Result<&1, &1, U32 & String, Unit>),
149 valid: Bool, source: S, destination: D, tls: Bool, chunk: U32, +cap: U32, ms: U32) ->
150 IO(S & D & Outcome):
151 match valid:
152 case False{}:
153 IO.pure(S & D & Outcome, (source, destination, Failed{0, BadChunk{}}))
154 case True{}:
155 transfer.loop(~S, ~D, ~read, ~write, 1n+U32.to_nat(cap),
156 More{source, destination, 0}, tls, chunk, cap, ms)