bytes.bend checks
raw source on the hub · import 0xd6fc55bf65b187fec4175f80d08c165a/bytes.bend as Bytes
Bytes: a List<&2, U32> of values below 256. Big-endian numbers (the network's order) and the little-endian ones RTMP has here and there, cuts of a buffer, and bytes as text. The loops are tail calls: a nested recursion costs a frame per byte in Bend, and a video frame is tens of thousands of bytes.
1 import
import Base
Types
type Cut source · line 88 · raw
Data
A buffer cut after its first n bytes: both parts, or Short when it has fewer (then nothing is taken).
ShortCut
Cut@head:List<&2, U32> -> @rest:List<&2, U32> -> Cut
Definitions
def Bytes.be source · line 12 · raw
@n:Nat -> @bs:List<&2, U32> -> @+acc:U32 -> U32
The big-endian number in the first n bytes (missing bytes count as 0).
def Bytes.u8 source · line 21 · raw
@bs:List<&2, U32> -> U32
def Bytes.u16 source · line 24 · raw
@bs:List<&2, U32> -> U32
def Bytes.u24 source · line 27 · raw
@bs:List<&2, U32> -> U32
def Bytes.u32 source · line 30 · raw
@bs:List<&2, U32> -> U32
def Bytes.u32le source · line 34 · raw
@bs:List<&2, U32> -> U32
The little-endian U32 in the first 4 bytes.
def Bytes.b source · line 41 · raw
@+x:U32 -> @n:Nat -> U32
def Bytes.put16 source · line 45 · raw
@+x:U32 -> @rest:List<&2, U32> -> List<&2, U32>
x as 2, 3 and 4 big-endian bytes, in front of rest.
def Bytes.put24 source · line 48 · raw
@+x:U32 -> @rest:List<&2, U32> -> List<&2, U32>
def Bytes.put32 source · line 51 · raw
@+x:U32 -> @rest:List<&2, U32> -> List<&2, U32>
def Bytes.put32le source · line 55 · raw
@+x:U32 -> @rest:List<&2, U32> -> List<&2, U32>
x as 4 little-endian bytes, in front of rest.
def Bytes.onto source · line 62 · raw
@acc:List<&2, U32> -> @tail:List<&2, U32> -> List<&2, U32>
acc reversed in front of tail.
def Bytes.rev source · line 69 · raw
@bs:List<&2, U32> -> List<&2, U32>
def Bytes.cat source · line 73 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> List<&2, U32>
a then b, without a frame per byte of a.
def Bytes.len.go source · line 76 · raw
@bs:List<&2, U32> -> @+n:U32 -> U32
def Bytes.len source · line 83 · raw
@bs:List<&2, U32> -> U32
def Bytes.cut.go source · line 92 · raw
@n:Nat -> @bs:List<&2, U32> -> @acc:List<&2, U32> -> Cut
def Bytes.cut source · line 101 · raw
@n:U32 -> @bs:List<&2, U32> -> Cut
def Bytes.drop source · line 104 · raw
@n:Nat -> @bs:List<&2, U32> -> List<&2, U32>
def Bytes.take.go source · line 111 · raw
@n:Nat -> @bs:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>
def Bytes.take source · line 119 · raw
@n:Nat -> @bs:List<&2, U32> -> List<&2, U32>
The first n bytes (fewer if there are fewer).
def Bytes.text.go source · line 125 · raw
@bs:List<&2, U32> -> @acc:String -> String
def Bytes.text source · line 133 · raw
@bs:List<&2, U32> -> String
Each byte as the char of that code (ASCII; Latin-1 above it).
def Bytes.of.go source · line 136 · raw
@s:String -> @acc:List<&2, U32> -> List<&2, U32>
def Bytes.of source · line 144 · raw
@s:String -> List<&2, U32>
Each char as one byte (for text known to be ASCII).
def Bytes.join source · line 148 · raw
@parts:List<&2, List<&2, U32>> -> @acc:List<&2, U32> -> List<&2, U32>
Parts kept last-first, joined in order in front of acc.
def Bytes.split.go source · line 155 · raw
@n:Nat -> @bs:List<&2, U32> -> @acc:List<&2, U32> -> Cut
def Bytes.split source · line 164 · raw
@n:Nat -> @bs:List<&2, U32> -> Cut
The first n bytes and the rest; all of it and nothing when it has fewer.