io.bend relies on unsafe/foreign
raw source on the hub · import bend-kit-f32array@0.2.0.0/io.bend as Io
File reads for packed F32 arrays, kept outside the pure proof imports.
4 imports
import Base import ./f32array.bend as A import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes import bend-kit-files@0.4.0.0/files.bend as Files
Types
type Read source · line 8 · raw
Type
A file read in progress: more bytes to read, or the final result.
More@file:File -> @acc:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @left:U32 -> Read
Stop@file:File -> @result:Result<&1, &1, Pair(U32, String), 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes> -> Read
Definitions
def read.next source · line 12 · raw
@more:Bool -> @file:File -> @acc:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+left:U32 -> Read
def read.step source · line 20 · raw
@got:Pair(File, Result<&1, &1, Pair(U32, String), 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes>) -> @acc:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+left:U32 -> Read
A read of no bytes ends the loop early, so a file that shrank stops there.
def read.loop source · line 30 · raw
@n:Nat -> @st:Read -> IO(Pair(File, Result<&1, &1, Pair(U32, String), 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes>))
Each pass reads at least one byte or stops, so left + 1 passes are enough.
def read.sized source · line 47 · raw
@sz:Pair(File, Result<&1, &1, Pair(U32, String), U32>) -> IO(Pair(File, Result<&1, &1, Pair(U32, String), 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes>))
def read.decode source · line 55 · raw
@m:Maybe<&1, 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array> -> Result<&1, &1, Pair(U32, String), 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>
def read.le source · line 77 · raw
@file:File -> IO(Pair(File, Result<&1, &1, Pair(U32, String), 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>))
The rest of an open file, four little-endian bytes per element. Fails EINVAL when its size is not a multiple of 4.
def read.be source · line 81 · raw
@file:File -> IO(Pair(File, Result<&1, &1, Pair(U32, String), 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>))
The rest of an open file, four big-endian bytes per element. Fails EINVAL when its size is not a multiple of 4.
Templates
template read.fin source · line 62 · raw
@-f:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&1, 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>) -> @got:Pair(File, Result<&1, &1, Pair(U32, String), 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes>) -> Pair(File, Result<&1, &1, Pair(U32, String), 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>)
template read.with source · line 70 · raw
@-f:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&1, 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>) -> @file:File -> IO(Pair(File, Result<&1, &1, Pair(U32, String), 0x0fe59af595d11753cb2b2a81171ef957/f32array.F32Array>))