aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/binary.lux
blob: e5f7e8067b2bd6dc5b1021c895b45d45a6aedf74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
(.using
 [library
  [lux (.except)
   ["$" documentation (.only documentation:)]
   [data
    [text (.only \n)
     ["%" format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(documentation: /.Binary
  "A binary BLOB of data.")

(documentation: /.empty
  "A fresh/empty binary BLOB of the specified size."
  [(empty size)])

(documentation: /.mix
  ""
  [(mix f init binary)])

(documentation: /.bits_8
  "Read 1 byte (8 bits) at the given index."
  [(bits_8 index binary)])

(documentation: /.bits_16
  "Read 2 bytes (16 bits) at the given index."
  [(bits_16 index binary)])

(documentation: /.bits_32
  "Read 4 bytes (32 bits) at the given index."
  [(bits_32 index binary)])

(documentation: /.bits_64
  "Read 8 bytes (64 bits) at the given index."
  [(bits_64 index binary)])

(documentation: /.has_8!
  "Write 1 byte (8 bits) at the given index."
  [(has_8! index value binary)])

(documentation: /.has_16!
  "Write 2 bytes (16 bits) at the given index."
  [(has_16! index value binary)])

(documentation: /.has_32!
  "Write 4 bytes (32 bits) at the given index."
  [(has_32! index value binary)])

(documentation: /.has_64!
  "Write 8 bytes (64 bits) at the given index."
  [(has_64! index value binary)])

(documentation: /.copy!
  "Mutates the target binary BLOB by copying bytes from the source BLOB to it."
  [(copy! bytes source_offset source target_offset target)])

(documentation: /.slice
  "Yields a subset of the binary BLOB, so long as the specified range is valid."
  [(slice offset length binary)])

(documentation: /.after
  "Yields a binary BLOB with at most the specified number of bytes removed."
  [(after bytes binary)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Binary
             ..empty
             ..mix
             ..bits_8
             ..bits_16
             ..bits_32
             ..bits_64
             ..has_8!
             ..has_16!
             ..has_32!
             ..has_64!
             ..copy!
             ..slice
             ..after
             ($.default /.index_out_of_bounds)
             ($.default /.slice_out_of_bounds)
             ($.default /.size)
             ($.default /.equivalence)
             ($.default /.monoid)]
            []))