~/bend-docscommunity

native.bend relies on unsafe/foreign

raw source on the hub · import bend-kit-zlib@0.6.1.0/native.bend as Native

Native gzip, zstd, and brotli over Bytes.

2 imports
import Base
import bend-kit-bytes@0.3.3.1/bytes.bend as Bytes

Types

type Decoder source · line 69 · raw

Type

A live native decoder. Call dec.finish even after a failed feed to release it.

Definitions

def words.got source · line 31 · raw

@r:Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)> -> Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>

def libz.inflate source · line 46 · raw

@max:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

gzip, zlib, or raw DEFLATE data through libz, selected from the first two bytes. Every gzip member is decoded in turn, as gzip -d does. Each decoder fails with EFBIG when the output passes max bytes, and ENOENT without its library.

def libz.inflate.raw source · line 50 · raw

@max:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

One raw DEFLATE stream through libz. Trailing bytes, truncated input and output above max fail.

def libz.gzip source · line 54 · raw

@b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

One gzip member at level 6 through libz.

def zstd source · line 61 · raw

@max:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

Zstandard frames (RFC 8878) through libzstd.

def brotli source · line 65 · raw

@max:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

Brotli (RFC 7932) through libbrotlidec.

def dec.new.got source · line 76 · raw

@r:Result<&1, &1, Pair(U32, String), U32> -> Result<&1, &1, Pair(U32, String), Decoder>

def dec.new source · line 83 · raw

@+kind:U32 -> IO(Result<&1, &1, Pair(U32, String), Decoder>)

def inflate.new source · line 88 · raw

IO(Result<&1, &1, Pair(U32, String), Decoder>)

def brotli.new source · line 91 · raw

IO(Result<&1, &1, Pair(U32, String), Decoder>)

def zstd.new source · line 94 · raw

IO(Result<&1, &1, Pair(U32, String), Decoder>)

def dec.push source · line 103 · raw

@d:Decoder -> @max:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Pair(Decoder, Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>))

The output of one chunk of input. max caps this call, not the total output of the stream.

def dec.finish source · line 116 · raw

@d:Decoder -> IO(Result<&1, &1, Pair(U32, String), Unit>)

Finish validates the end marker and always releases the decoder.

Templates

template words.run source · line 38 · raw

@-eff:(@_:U32 -> @_:U32 -> @_:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)) -> @max:U32 -> @b:0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes -> IO(Result<&1, &1, Pair(U32, String), 0xec25e4adfb02e59e4b817801115988ee/bytes.Bytes>)

Effects (foreign code)

effect zstd.words source · line 6 · raw

@max:U32 -> @len:U32 -> @words:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)

The C libraries, through packed words at the effect boundary. Call the Bytes wrappers below.

foreign: effs/zlib.c, effs/zlib.js

effect inflate.words source · line 11 · raw

@max:U32 -> @len:U32 -> @words:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)

foreign: effs/zlib.c, effs/zlib.js

effect inflate.raw.words source · line 16 · raw

@max:U32 -> @len:U32 -> @words:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)

foreign: effs/zlib.c, effs/zlib.js

effect gzip.words source · line 21 · raw

@len:U32 -> @words:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)

foreign: effs/zlib.c, effs/zlib.js

effect brotli.words source · line 26 · raw

@max:U32 -> @len:U32 -> @words:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)

foreign: effs/zlib.c, effs/zlib.js

effect dec.open source · line 72 · raw

@kind:U32 -> IO(Result<&1, &1, Pair(U32, String), U32>)

foreign: effs/zlib.c, effs/zlib.js

effect dec.feed source · line 97 · raw

@id:U32 -> @max:U32 -> @len:U32 -> @words:Array<U32> -> IO(Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>)

foreign: effs/zlib.c, effs/zlib.js

effect dec.finish.id source · line 111 · raw

@id:U32 -> IO(Result<&1, &1, Pair(U32, String), Unit>)

foreign: effs/zlib.c, effs/zlib.js