bytes.bend checks
raw source on the hub · import bend-kit-bytes@0.3.3.2/bytes.bend as Bytes
Byte buffers packed four bytes to a U32, with bounds-checked access. Source: https://github.com/paymog/bend-kit/tree/main/bytes
2 imports
import Base import bend-kit-int@0.2.0.0/int.bend as Int
Types
type Bytes source · line 10 · raw
Type
Bytes@len:U32 -> @buf:Array<U32> -> Bytes
type Cursor source · line 807 · raw
Type
A cursor owns the same packed buffer; start and end bound a region without slicing it.
Cursor@bytes:Bytes -> @pos:U32 -> @start:U32 -> @end:U32 -> Cursor
type CursorLimit source · line 810 · raw
Type
CursorLimit@resume:U32 -> @start:U32 -> @end:U32 -> CursorLimit
Definitions
def b8 source · line 13 · raw
@+x:U32 -> U32
def shift source · line 16 · raw
@+i:U32 -> Nat
def words source · line 19 · raw
@+n:U32 -> U32
def depth.go source · line 23 · raw
@f:Nat -> @more:Bool -> @+w:U32 -> @+d:Nat -> @+cap:U32 -> Nat
The fewest d with 2^d >= w.
def depth source · line 34 · raw
@+w:U32 -> Nat
def alloc source · line 37 · raw
@+n:U32 -> Array<U32>
def peek.of source · line 41 · raw
@+sh:Nat -> @r:Pair(Array<U32>, U32) -> Pair(Array<U32>, U32)
Unchecked byte read and write. Callers keep i below len.
def peek source · line 45 · raw
@a:Array<U32> -> @+i:U32 -> Pair(Array<U32>, U32)
def poke.of source · line 48 · raw
@+i:U32 -> @+v:U32 -> @r:Pair(Array<U32>, U32) -> Array<U32>
def poke source · line 53 · raw
@a:Array<U32> -> @+i:U32 -> @+v:U32 -> Array<U32>
def copy.go source · line 57 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> @+s:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
n bytes from src[s..] to dst[d..], one byte at a time.
def copy.bytes source · line 66 · raw
@+m:U32 -> @src:Array<U32> -> @dst:Array<U32> -> @+s:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
def copy.words source · line 70 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> @+s:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
n words from src[s..] to dst[d..] (word indexes).
def copy.shift source · line 81 · raw
@n:Nat -> @+lo:Nat -> @+hi:Nat -> @+prev:U32 -> @r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> @+k:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
m bytes to a word-aligned d from an unaligned s: each out word joins two source words. lo = 8*(s%4) and hi = 32 - lo; r holds source word k, prev the word before it.
def copy.shift.at source · line 90 · raw
@+w:U32 -> @+lo:U32 -> @+k:U32 -> @+d:U32 -> @r:Pair(Array<U32>, U32) -> @dst:Array<U32> -> Pair(Array<U32>, Array<U32>)
def copy.tail source · line 94 · raw
@+m:U32 -> @+s:U32 -> @+d:U32 -> @r:Pair(Array<U32>, Array<U32>) -> Pair(Array<U32>, Array<U32>)
def copy.pick source · line 98 · raw
@aligned:Bool -> @+m:U32 -> @src:Array<U32> -> @dst:Array<U32> -> @+s:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
def copy.dst source · line 109 · raw
@daligned:Bool -> @+m:U32 -> @src:Array<U32> -> @dst:Array<U32> -> @+s:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
def copy source · line 118 · raw
@+m:U32 -> @src:Array<U32> -> @dst:Array<U32> -> @+s:U32 -> @+d:U32 -> Pair(Array<U32>, Array<U32>)
m bytes from src[s..] to dst[d..]. Whole words when d is word-aligned, shifted when s is not. ponytail: an unaligned d (append after an odd length) copies bytes; merge into d's first word if that gets hot.
def new source · line 122 · raw
@+n:U32 -> Bytes
n zero bytes.
def length source · line 125 · raw
@b:Bytes -> Pair(Bytes, U32)
def get.some source · line 129 · raw
@+len:U32 -> @r:Pair(Array<U32>, U32) -> Pair(Bytes, Maybe<&2, U32>)
def get.if source · line 133 · raw
@ok:Bool -> @+len:U32 -> @buf:Array<U32> -> @+i:U32 -> Pair(Bytes, Maybe<&2, U32>)
def get source · line 141 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, U32>)
Byte i, or None when i >= len.
def set.if source · line 145 · raw
@ok:Bool -> @+len:U32 -> @buf:Array<U32> -> @+i:U32 -> @+v:U32 -> Bytes
def set source · line 153 · raw
@b:Bytes -> @+i:U32 -> @+v:U32 -> Bytes
Byte i becomes v & 255. Nothing changes when i >= len.
def step source · line 158 · raw
@+up:Bool -> @+i:U32 -> U32
The next index: one forward when up, one back when not.
def fits source · line 162 · raw
@+len:U32 -> @+i:U32 -> @+n:U32 -> Bool
Do n bytes from i fit in len?
def uint.go source · line 166 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+j:U32 -> @+up:Bool -> @+acc:U32 -> Pair(Array<U32>, U32)
n bytes from j, each shifted in below the ones before: the first byte read is the most significant.
def uint.if source · line 176 · raw
@ok:Bool -> @+len:U32 -> @buf:Array<U32> -> @+i:U32 -> @+n:U32 -> @+be:Bool -> Pair(Bytes, Maybe<&2, U32>)
Big-endian reads forward from i; little-endian reads back from the last byte.
def uint source · line 184 · raw
@b:Bytes -> @+i:U32 -> @+n:U32 -> @+be:Bool -> Pair(Bytes, Maybe<&2, U32>)
def get.u16be source · line 190 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, U32>)
Unsigned integers at byte i, or None when they run past len. be: most significant byte first (network order); le: least significant first.
def get.u16le source · line 193 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, U32>)
def get.u32be source · line 196 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, U32>)
def get.u32le source · line 199 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, U32>)
def put.go source · line 203 · raw
@n:Nat -> @a:Array<U32> -> @+j:U32 -> @+up:Bool -> @+v:U32 -> Array<U32>
n bytes of v from j, least significant first.
def put.if source · line 211 · raw
@ok:Bool -> @+len:U32 -> @buf:Array<U32> -> @+i:U32 -> @+n:U32 -> @+be:Bool -> @+v:U32 -> Bytes
Little-endian writes forward from i; big-endian writes back from the last byte.
def put source · line 218 · raw
@b:Bytes -> @+i:U32 -> @+n:U32 -> @+be:Bool -> @+v:U32 -> Bytes
def set.u16be source · line 223 · raw
@b:Bytes -> @+i:U32 -> @+v:U32 -> Bytes
v's low 16 or 32 bits at byte i. Nothing changes when they would run past len.
def set.u16le source · line 226 · raw
@b:Bytes -> @+i:U32 -> @+v:U32 -> Bytes
def set.u32be source · line 229 · raw
@b:Bytes -> @+i:U32 -> @+v:U32 -> Bytes
def set.u32le source · line 232 · raw
@b:Bytes -> @+i:U32 -> @+v:U32 -> Bytes
def u64.of source · line 236 · raw
@be:Bool -> @+x:U32 -> @+y:U32 -> 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64
The U64 whose words, in byte order, are x then y.
def u64.join source · line 243 · raw
@+be:Bool -> @x:Maybe<&2, U32> -> @y:Maybe<&2, U32> -> Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>
def u64.lo source · line 250 · raw
@+be:Bool -> @x:Maybe<&2, U32> -> @r:Pair(Bytes, Maybe<&2, U32>) -> Pair(Bytes, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
def u64.hi source · line 254 · raw
@+i:U32 -> @+be:Bool -> @r:Pair(Bytes, Maybe<&2, U32>) -> Pair(Bytes, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
def u64 source · line 258 · raw
@b:Bytes -> @+i:U32 -> @+be:Bool -> Pair(Bytes, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
def get.u64be source · line 262 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
A U64 at byte i, or None when its 8 bytes run past len.
def get.u64le source · line 265 · raw
@b:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
def put64.if source · line 269 · raw
@ok:Bool -> @+len:U32 -> @buf:Array<U32> -> @+i:U32 -> @+be:Bool -> @+x:U32 -> @+y:U32 -> Bytes
Writes words x then y at byte i, both in the same byte order.
def put64 source · line 276 · raw
@b:Bytes -> @+i:U32 -> @+be:Bool -> @+v:0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64 -> Bytes
def set.u64be source · line 283 · raw
@b:Bytes -> @+i:U32 -> @+v:0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64 -> Bytes
v at byte i. Nothing changes when its 8 bytes would run past len.
def set.u64le source · line 286 · raw
@b:Bytes -> @+i:U32 -> @+v:0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64 -> Bytes
def count source · line 290 · raw
@s:String -> @+n:U32 -> U32
String.length counts in Nat, which costs more than the walk itself.
def flush source · line 298 · raw
@full:Bool -> @a:Array<U32> -> @+k:U32 -> @+w:U32 -> Array<U32>
Bytes enter at the top of w and shift down, so a full word has byte 0 lowest.
def from.go source · line 305 · raw
@s:String -> @a:Array<U32> -> @+i:U32 -> @+w:U32 -> Array<U32>
def from_string source · line 316 · raw
@+s:String -> Bytes
A byte string (one Char per octet, as Wire and Http use) to Bytes. Each Char keeps its low 8 bits.
def to.go source · line 320 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @acc:String -> String
def to_string source · line 329 · raw
@b:Bytes -> String
Bytes to a byte string, one Char per octet.
def slice.fin source · line 333 · raw
@+len:U32 -> @+m:U32 -> @r:Pair(Array<U32>, Array<U32>) -> Pair(Bytes, Bytes)
def slice.at source · line 337 · raw
@+len:U32 -> @buf:Array<U32> -> @+s:U32 -> @+m:U32 -> Pair(Bytes, Bytes)
def slice source · line 341 · raw
@b:Bytes -> @+start:U32 -> @+n:U32 -> Pair(Bytes, Bytes)
The buffer back, and a copy of up to n bytes from start. Both ends are clamped to len.
def clone.of source · line 346 · raw
@+len:U32 -> @r:Pair(Array<U32>, Array<U32>) -> Pair(Bytes, Bytes)
def clone source · line 351 · raw
@b:Bytes -> Pair(Bytes, Bytes)
Two buffers that hold the same bytes.
def dst source · line 355 · raw
@r:Pair(Array<U32>, Array<U32>) -> Array<U32>
def room source · line 360 · raw
@+len:U32 -> @+n:U32 -> Bool
Does a buffer holding len bytes have room for n? Its 2^d words fit the fewest that hold len.
def grow.if source · line 363 · raw
@fits:Bool -> @+len:U32 -> @buf:Array<U32> -> @+n:U32 -> Array<U32>
def grow source · line 371 · raw
@+len:U32 -> @buf:Array<U32> -> @+n:U32 -> Array<U32>
buf, or a copy of its first len bytes in the fewest 2^d words that hold n.
def append source · line 376 · raw
@a:Bytes -> @b:Bytes -> Bytes
a then b. b is written into a's buffer while it has room, and the buffer at least doubles when it runs out, so building a buffer one piece at a time is O(total).
def concat.total.con source · line 382 · raw
@x:Bytes -> @r:Pair(List<&1, Bytes>, U32) -> Pair(List<&1, Bytes>, U32)
def concat.total source · line 386 · raw
@xs:List<&1, Bytes> -> @+n:U32 -> Pair(List<&1, Bytes>, U32)
def concat.go source · line 394 · raw
@xs:List<&1, Bytes> -> @out:Array<U32> -> @+at:U32 -> Array<U32>
def concat.of source · line 402 · raw
@r:Pair(List<&1, Bytes>, U32) -> Bytes
def concat source · line 407 · raw
@xs:List<&1, Bytes> -> Bytes
The pieces in order, in one new buffer: one copy per byte, however many pieces.
def at.go source · line 411 · raw
@needle:String -> @ok:Bool -> @r:Pair(Array<U32>, U32) -> @+j:U32 -> Pair(Array<U32>, Bool)
Does needle match at j? ok is the previous byte's result; the first mismatch stops the walk.
def at source · line 425 · raw
@a:Array<U32> -> @+needle:String -> @+j:U32 -> Pair(Array<U32>, Bool)
def find.go source · line 430 · raw
@f:Nat -> @r:Pair(Array<U32>, Bool) -> @+needle:String -> @+i:U32 -> @+up:Bool -> Pair(Array<U32>, Maybe<&2, U32>)
ponytail: naive search; a mismatch costs one byte read per position, but a repetitive needle is O(len * needle). Add a SWAR scan or two-way search if find gets hot. f counts the positions left after i.
def find.fin source · line 443 · raw
@+len:U32 -> @r:Pair(Array<U32>, Maybe<&2, U32>) -> Pair(Bytes, Maybe<&2, U32>)
def find.at source · line 447 · raw
@none:Bool -> @+len:U32 -> @buf:Array<U32> -> @+needle:String -> @+i:U32 -> @+f:U32 -> @+up:Bool -> Pair(Bytes, Maybe<&2, U32>)
def find.from source · line 456 · raw
@b:Bytes -> @+needle:String -> @+start:U32 -> Pair(Bytes, Maybe<&2, U32>)
Index of the first match of needle (a byte string) at or after start, or None. An empty needle matches at start when start <= len.
def find source · line 462 · raw
@b:Bytes -> @+needle:String -> Pair(Bytes, Maybe<&2, U32>)
Index of the first match of needle (a byte string), or None. An empty needle matches at 0.
def rfind source · line 466 · raw
@b:Bytes -> @+needle:String -> Pair(Bytes, Maybe<&2, U32>)
Index of the last match of needle, or None. An empty needle matches at len.
def at.fin source · line 471 · raw
@+len:U32 -> @r:Pair(Array<U32>, Bool) -> Pair(Bytes, Bool)
def at.if source · line 475 · raw
@fits:Bool -> @+len:U32 -> @buf:Array<U32> -> @+needle:String -> @+j:U32 -> Pair(Bytes, Bool)
def starts_with source · line 483 · raw
@b:Bytes -> @+prefix:String -> Pair(Bytes, Bool)
Does b begin with prefix (a byte string)?
def ends_with source · line 489 · raw
@b:Bytes -> @+suffix:String -> Pair(Bytes, Bool)
Does b end with suffix (a byte string)?
def split.scan source · line 496 · raw
@f:Nat -> @r:Pair(Array<U32>, Bool) -> @+sep:String -> @+m:U32 -> @+i:U32 -> @+skip:U32 -> @+cuts:List<&2, U32> -> Pair(Array<U32>, List<&2, U32>)
Match positions of sep, latest first, that do not overlap an earlier match. f counts the positions left; skip counts the bytes still inside the last match.
def snd source · line 507 · raw
@r:Pair(Bytes, Bytes) -> Bytes
def split.cut source · line 512 · raw
@cuts:List<&2, U32> -> @r:Pair(Bytes, Bytes) -> @+end:U32 -> @+m:U32 -> @acc:List<&1, Bytes> -> List<&1, Bytes>
r holds the buffer and the piece that ends at end; each earlier cut j starts one at j + m.
def split.of source · line 521 · raw
@cuts:List<&2, U32> -> @b:Bytes -> @+len:U32 -> @+m:U32 -> List<&1, Bytes>
def split.run source · line 528 · raw
@+len:U32 -> @+m:U32 -> @r:Pair(Array<U32>, List<&2, U32>) -> List<&1, Bytes>
def split.if source · line 532 · raw
@whole:Bool -> @+len:U32 -> @buf:Array<U32> -> @+sep:String -> @+m:U32 -> List<&1, Bytes>
def split source · line 541 · raw
@b:Bytes -> @+sep:String -> List<&1, Bytes>
The pieces between matches of sep (a byte string), left to right. n matches give n + 1 pieces, so a match at either end gives an empty piece. An empty sep gives b whole.
def eq.go source · line 547 · raw
@n:Nat -> @same:Bool -> @r:Pair(Array<U32>, U32) -> @s:Pair(Array<U32>, U32) -> @+i:U32 -> Pair(Array<U32>, Pair(Array<U32>, Bool))
Compares whole words; same tells whether the previous pair matched.
def eq.fin source · line 564 · raw
@+la:U32 -> @+lb:U32 -> @r:Pair(Array<U32>, Pair(Array<U32>, Bool)) -> Pair(Bytes, Pair(Bytes, Bool))
def eq.len source · line 568 · raw
@same:Bool -> @+la:U32 -> @xa:Array<U32> -> @+lb:U32 -> @ya:Array<U32> -> Pair(Bytes, Pair(Bytes, Bool))
def eq source · line 576 · raw
@a:Bytes -> @b:Bytes -> Pair(Bytes, Pair(Bytes, Bool))
Both buffers back, and whether they hold the same bytes.
def bswap source · line 582 · raw
@+w:U32 -> U32
Byte 0 of w becomes the most significant, so words compare in byte order.
def cmp.go source · line 586 · raw
@n:Nat -> @c:Cmp -> @r:Pair(Array<U32>, U32) -> @s:Pair(Array<U32>, U32) -> @+i:U32 -> Pair(Array<U32>, Pair(Array<U32>, Cmp))
Compares whole words; c is the previous pair's order.
def cmp.len source · line 607 · raw
@c:Cmp -> @+la:U32 -> @+lb:U32 -> Cmp
def cmp.fin source · line 616 · raw
@+la:U32 -> @+lb:U32 -> @r:Pair(Array<U32>, Pair(Array<U32>, Cmp)) -> Pair(Bytes, Pair(Bytes, Cmp))
def cmp source · line 622 · raw
@a:Bytes -> @b:Bytes -> Pair(Bytes, Pair(Bytes, Cmp))
Both buffers back, and their order byte by byte; a prefix sorts first. The shorter buffer's bytes past its len are 0, so its last word compares low when only the longer one goes on.
def nibble source · line 627 · raw
@+n:U32 -> Char
def hex.go source · line 630 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @acc:String -> String
def to_hex source · line 639 · raw
@b:Bytes -> String
Two lowercase hex digits per byte.
def in source · line 643 · raw
@+lo:U32 -> @+c:U32 -> @+hi:U32 -> Bool
def unnibble source · line 647 · raw
@+c:U32 -> U32
A hex digit's value, or 16.
def poke.when source · line 650 · raw
@write:Bool -> @a:Array<U32> -> @+i:U32 -> @+v:U32 -> Array<U32>
def unhex.go source · line 658 · raw
@s:String -> @a:Array<U32> -> @+i:U32 -> @+hi:U32 -> @+ok:Bool -> Pair(Array<U32>, Bool)
hi is the previous digit; an odd i completes a byte.
def decoded source · line 666 · raw
@+n:U32 -> @r:Pair(Array<U32>, Bool) -> Maybe<&1, Bytes>
def unhex.if source · line 674 · raw
@even:Bool -> @+s:String -> @+n:U32 -> Maybe<&1, Bytes>
def from_hex source · line 682 · raw
@+s:String -> Maybe<&1, Bytes>
Hex digits, either case, to bytes. None for an odd count or a non-hex char.
def b64.char source · line 687 · raw
@+i:U32 -> U32
RFC 4648 §4: the standard alphabet, padded with '='.
def b64.at source · line 691 · raw
@+v:U32 -> @+k:Nat -> Char
The six bits of v at k as a base64 char.
def b64.go source · line 695 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @acc:String -> String
Groups of three bytes, last first; r holds the 24 bits of the group at i.
def b64.tail source · line 705 · raw
@+rem:U32 -> @+t:U32 -> @+q:U32 -> @r:Pair(Array<U32>, U32) -> String
The rem < 3 bytes after the last whole group, then the groups before them.
def to_base64 source · line 713 · raw
@b:Bytes -> String
Base64 (RFC 4648 §4) with '=' padding.
def b64.val source · line 720 · raw
@+c:U32 -> U32
A base64 char's value, 64 for '=', or 65.
def b64.pads source · line 724 · raw
@s:String -> @+run:U32 -> U32
The count of '=' at the end of s.
def b64.put source · line 732 · raw
@full:Bool -> @a:Array<U32> -> @+o:U32 -> @+w:U32 -> @+v:U32 -> Array<U32>
A whole group of four chars writes its bytes at o, as many as fit before len.
def unb64.go source · line 740 · raw
@s:String -> @a:Array<U32> -> @+i:U32 -> @+v:U32 -> @+ok:Bool -> @+len:U32 -> @+body:U32 -> Pair(Array<U32>, Bool)
v collects six bits per char. '=' is allowed only at body and after.
def unb64.if source · line 751 · raw
@ok:Bool -> @+s:String -> @+n:U32 -> @+pads:U32 -> Maybe<&1, Bytes>
def from_base64 source · line 761 · raw
@+s:String -> Maybe<&1, Bytes>
Padded base64 (RFC 4648 §4) to bytes. None for a length that is not a multiple of 4, more than two '=', '=' before the end, or a char outside the alphabet.
def u32.read.go source · line 767 · raw
@n:Nat -> @r:Pair(Array<U32>, U32) -> @+i:U32 -> @+acc:U32 -> @+ok:Bool -> Maybe<&2, U32>
For a digit d, n * 10 + d overflows exactly when (n * 10 + d) / 10 != n in wrapping U32.
def u32.read source · line 778 · raw
@b:Bytes -> Maybe<&2, U32>
ASCII decimal digits to a U32. None when b is empty, holds a non-digit, or exceeds 4294967295.
def u32.width source · line 783 · raw
@f:Nat -> @small:Bool -> @+n:U32 -> @+k:U32 -> U32
The digit count of n, at most 10.
def u32.digits source · line 794 · raw
@f:Nat -> @a:Array<U32> -> @+i:U32 -> @+n:U32 -> Array<U32>
def u32.show source · line 802 · raw
@+n:U32 -> Bytes
n in ASCII decimal, with no leading zeros.
def Cursor.new source · line 813 · raw
@b:Bytes -> Cursor
def Cursor.finish source · line 817 · raw
@c:Cursor -> Pair(Bytes, U32)
def Cursor.position source · line 821 · raw
@c:Cursor -> Pair(Cursor, U32)
def Cursor.remaining source · line 825 · raw
@c:Cursor -> Pair(Cursor, U32)
def Cursor.fits source · line 829 · raw
@+len:U32 -> @+pos:U32 -> @+start:U32 -> @+end:U32 -> @+n:U32 -> Bool
def Cursor.seek.if source · line 832 · raw
@ok:Bool -> @c:Cursor -> @+pos:U32 -> Pair(Cursor, Bool)
def Cursor.seek source · line 840 · raw
@c:Cursor -> @+pos:U32 -> Pair(Cursor, Bool)
def Cursor.skip source · line 844 · raw
@c:Cursor -> @+n:U32 -> Pair(Cursor, Bool)
def Cursor.region.if source · line 849 · raw
@ok:Bool -> @c:Cursor -> @+n:U32 -> Pair(Cursor, Maybe<&1, CursorLimit>)
On success, read inside the region, then leave with the returned affine limit.
def Cursor.region source · line 858 · raw
@c:Cursor -> @+n:U32 -> Pair(Cursor, Maybe<&1, CursorLimit>)
def Cursor.leave source · line 862 · raw
@c:Cursor -> @limit:CursorLimit -> Cursor
def Cursor.u8 source · line 887 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, U32>)
def Cursor.u16be source · line 890 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, U32>)
def Cursor.u16le source · line 893 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, U32>)
def Cursor.u32be source · line 896 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, U32>)
def Cursor.u32le source · line 899 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, U32>)
def Cursor.u64be source · line 902 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
def Cursor.u64le source · line 905 · raw
@c:Cursor -> Pair(Cursor, Maybe<&2, 0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64>)
def Cursor.put.u8 source · line 920 · raw
@c:Cursor -> @v:U32 -> Pair(Cursor, Bool)
def Cursor.put.u16be source · line 923 · raw
@c:Cursor -> @v:U32 -> Pair(Cursor, Bool)
def Cursor.put.u16le source · line 926 · raw
@c:Cursor -> @v:U32 -> Pair(Cursor, Bool)
def Cursor.put.u32be source · line 929 · raw
@c:Cursor -> @v:U32 -> Pair(Cursor, Bool)
def Cursor.put.u32le source · line 932 · raw
@c:Cursor -> @v:U32 -> Pair(Cursor, Bool)
def Cursor.put.u64be source · line 935 · raw
@c:Cursor -> @v:0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64 -> Pair(Cursor, Bool)
def Cursor.put.u64le source · line 938 · raw
@c:Cursor -> @v:0x4eed9d7ac6ece61523d747a9d804e4f0/int.U64 -> Pair(Cursor, Bool)
Templates
template Cursor.read.done source · line 867 · raw
@-T:Data -> @+pos:U32 -> @start:U32 -> @end:U32 -> @+n:U32 -> @r:Pair(Bytes, Maybe<&2, T>) -> Pair(Cursor, Maybe<&2, T>)
template Cursor.read.if source · line 875 · raw
@-T:Data -> @-read:(@_:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, T>)) -> @ok:Bool -> @c:Cursor -> @+n:U32 -> Pair(Cursor, Maybe<&2, T>)
template Cursor.read source · line 883 · raw
@-T:Data -> @-read:(@_:Bytes -> @+i:U32 -> Pair(Bytes, Maybe<&2, T>)) -> @c:Cursor -> @+n:U32 -> Pair(Cursor, Maybe<&2, T>)
template Cursor.write.if source · line 908 · raw
@-T:Data -> @-write:(@_:Bytes -> @+i:U32 -> @+v:T -> Bytes) -> @ok:Bool -> @c:Cursor -> @+n:U32 -> @v:T -> Pair(Cursor, Bool)
template Cursor.write source · line 916 · raw
@-T:Data -> @-write:(@_:Bytes -> @+i:U32 -> @+v:T -> Bytes) -> @c:Cursor -> @+n:U32 -> @v:T -> Pair(Cursor, Bool)