1Stdlib.BytesLabels(3) OCaml library Stdlib.BytesLabels(3)
2
3
4
6 Stdlib.BytesLabels - no description
7
9 Module Stdlib.BytesLabels
10
12 Module BytesLabels
13 : (module Stdlib__BytesLabels)
14
15
16
17
18
19
20
21
22 val length : bytes -> int
23
24 Return the length (number of bytes) of the argument.
25
26
27
28 val get : bytes -> int -> char
29
30
31 get s n returns the byte at index n in argument s .
32
33
34 Raises Invalid_argument if n is not a valid index in s .
35
36
37
38 val set : bytes -> int -> char -> unit
39
40
41 set s n c modifies s in place, replacing the byte at index n with c .
42
43
44 Raises Invalid_argument if n is not a valid index in s .
45
46
47
48 val create : int -> bytes
49
50
51 create n returns a new byte sequence of length n . The sequence is
52 uninitialized and contains arbitrary bytes.
53
54
55 Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
56
57
58
59 val make : int -> char -> bytes
60
61
62 make n c returns a new byte sequence of length n , filled with the byte
63 c .
64
65
66 Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
67
68
69
70 val init : int -> f:(int -> char) -> bytes
71
72
73 init n f returns a fresh byte sequence of length n , with character i
74 initialized to the result of f i (in increasing index order).
75
76
77 Raises Invalid_argument if n < 0 or n > Sys.max_string_length .
78
79
80
81 val empty : bytes
82
83 A byte sequence of size 0.
84
85
86
87 val copy : bytes -> bytes
88
89 Return a new byte sequence that contains the same bytes as the argu‐
90 ment.
91
92
93
94 val of_string : string -> bytes
95
96 Return a new byte sequence that contains the same bytes as the given
97 string.
98
99
100
101 val to_string : bytes -> string
102
103 Return a new string that contains the same bytes as the given byte se‐
104 quence.
105
106
107
108 val sub : bytes -> pos:int -> len:int -> bytes
109
110
111 sub s ~pos ~len returns a new byte sequence of length len , containing
112 the subsequence of s that starts at position pos and has length len .
113
114
115 Raises Invalid_argument if pos and len do not designate a valid range
116 of s .
117
118
119
120 val sub_string : bytes -> pos:int -> len:int -> string
121
122 Same as BytesLabels.sub but return a string instead of a byte sequence.
123
124
125
126 val extend : bytes -> left:int -> right:int -> bytes
127
128
129 extend s ~left ~right returns a new byte sequence that contains the
130 bytes of s , with left uninitialized bytes prepended and right unini‐
131 tialized bytes appended to it. If left or right is negative, then bytes
132 are removed (instead of appended) from the corresponding side of s .
133
134
135 Since 4.05.0 in BytesLabels
136
137
138 Raises Invalid_argument if the result length is negative or longer than
139 Sys.max_string_length bytes.
140
141
142
143 val fill : bytes -> pos:int -> len:int -> char -> unit
144
145
146 fill s ~pos ~len c modifies s in place, replacing len characters with c
147 , starting at pos .
148
149
150 Raises Invalid_argument if pos and len do not designate a valid range
151 of s .
152
153
154
155 val blit : src:bytes -> src_pos:int -> dst:bytes -> dst_pos:int ->
156 len:int -> unit
157
158
159 blit ~src ~src_pos ~dst ~dst_pos ~len copies len bytes from sequence
160 src , starting at index src_pos , to sequence dst , starting at index
161 dst_pos . It works correctly even if src and dst are the same byte se‐
162 quence, and the source and destination intervals overlap.
163
164
165 Raises Invalid_argument if src_pos and len do not designate a valid
166 range of src , or if dst_pos and len do not designate a valid range of
167 dst .
168
169
170
171 val blit_string : src:string -> src_pos:int -> dst:bytes -> dst_pos:int
172 -> len:int -> unit
173
174
175 blit ~src ~src_pos ~dst ~dst_pos ~len copies len bytes from string src
176 , starting at index src_pos , to byte sequence dst , starting at index
177 dst_pos .
178
179
180 Since 4.05.0 in BytesLabels
181
182
183 Raises Invalid_argument if src_pos and len do not designate a valid
184 range of src , or if dst_pos and len do not designate a valid range of
185 dst .
186
187
188
189 val concat : sep:bytes -> bytes list -> bytes
190
191
192 concat ~sep sl concatenates the list of byte sequences sl , inserting
193 the separator byte sequence sep between each, and returns the result as
194 a new byte sequence.
195
196
197 Raises Invalid_argument if the result is longer than
198 Sys.max_string_length bytes.
199
200
201
202 val cat : bytes -> bytes -> bytes
203
204
205 cat s1 s2 concatenates s1 and s2 and returns the result as a new byte
206 sequence.
207
208
209 Since 4.05.0 in BytesLabels
210
211
212 Raises Invalid_argument if the result is longer than
213 Sys.max_string_length bytes.
214
215
216
217 val iter : f:(char -> unit) -> bytes -> unit
218
219
220 iter ~f s applies function f in turn to all the bytes of s . It is
221 equivalent to f (get s 0); f (get s 1); ...; f (get s
222 (length s - 1)); () .
223
224
225
226 val iteri : f:(int -> char -> unit) -> bytes -> unit
227
228 Same as BytesLabels.iter , but the function is applied to the index of
229 the byte as first argument and the byte itself as second argument.
230
231
232
233 val map : f:(char -> char) -> bytes -> bytes
234
235
236 map ~f s applies function f in turn to all the bytes of s (in increas‐
237 ing index order) and stores the resulting bytes in a new sequence that
238 is returned as the result.
239
240
241
242 val mapi : f:(int -> char -> char) -> bytes -> bytes
243
244
245 mapi ~f s calls f with each character of s and its index (in increasing
246 index order) and stores the resulting bytes in a new sequence that is
247 returned as the result.
248
249
250
251 val fold_left : f:('a -> char -> 'a) -> init:'a -> bytes -> 'a
252
253
254 fold_left f x s computes f (... (f (f x (get s 0)) (get s 1)) ...) (get
255 s (n-1)) , where n is the length of s .
256
257
258 Since 4.13.0
259
260
261
262 val fold_right : f:(char -> 'a -> 'a) -> bytes -> init:'a -> 'a
263
264
265 fold_right f s x computes f (get s 0) (f (get s 1) ( ... (f (get s
266 (n-1)) x) ...)) , where n is the length of s .
267
268
269 Since 4.13.0
270
271
272
273 val for_all : f:(char -> bool) -> bytes -> bool
274
275
276 for_all p s checks if all characters in s satisfy the predicate p .
277
278
279 Since 4.13.0
280
281
282
283 val exists : f:(char -> bool) -> bytes -> bool
284
285
286 exists p s checks if at least one character of s satisfies the predi‐
287 cate p .
288
289
290 Since 4.13.0
291
292
293
294 val trim : bytes -> bytes
295
296 Return a copy of the argument, without leading and trailing whitespace.
297 The bytes regarded as whitespace are the ASCII characters ' ' , '\012'
298 , '\n' , '\r' , and '\t' .
299
300
301
302 val escaped : bytes -> bytes
303
304 Return a copy of the argument, with special characters represented by
305 escape sequences, following the lexical conventions of OCaml. All
306 characters outside the ASCII printable range (32..126) are escaped, as
307 well as backslash and double-quote.
308
309
310 Raises Invalid_argument if the result is longer than
311 Sys.max_string_length bytes.
312
313
314
315 val index : bytes -> char -> int
316
317
318 index s c returns the index of the first occurrence of byte c in s .
319
320
321 Raises Not_found if c does not occur in s .
322
323
324
325 val index_opt : bytes -> char -> int option
326
327
328 index_opt s c returns the index of the first occurrence of byte c in s
329 or None if c does not occur in s .
330
331
332 Since 4.05
333
334
335
336 val rindex : bytes -> char -> int
337
338
339 rindex s c returns the index of the last occurrence of byte c in s .
340
341
342 Raises Not_found if c does not occur in s .
343
344
345
346 val rindex_opt : bytes -> char -> int option
347
348
349 rindex_opt s c returns the index of the last occurrence of byte c in s
350 or None if c does not occur in s .
351
352
353 Since 4.05
354
355
356
357 val index_from : bytes -> int -> char -> int
358
359
360 index_from s i c returns the index of the first occurrence of byte c in
361 s after position i . index s c is equivalent to index_from s 0 c .
362
363
364 Raises Invalid_argument if i is not a valid position in s .
365
366
367 Raises Not_found if c does not occur in s after position i .
368
369
370
371 val index_from_opt : bytes -> int -> char -> int option
372
373
374 index_from_opt s i c returns the index of the first occurrence of byte
375 c in s after position i or None if c does not occur in s after position
376 i . index_opt s c is equivalent to index_from_opt s 0 c .
377
378
379 Since 4.05
380
381
382 Raises Invalid_argument if i is not a valid position in s .
383
384
385
386 val rindex_from : bytes -> int -> char -> int
387
388
389 rindex_from s i c returns the index of the last occurrence of byte c in
390 s before position i+1 . rindex s c is equivalent to rindex_from s
391 (length s - 1) c .
392
393
394 Raises Invalid_argument if i+1 is not a valid position in s .
395
396
397 Raises Not_found if c does not occur in s before position i+1 .
398
399
400
401 val rindex_from_opt : bytes -> int -> char -> int option
402
403
404 rindex_from_opt s i c returns the index of the last occurrence of byte
405 c in s before position i+1 or None if c does not occur in s before po‐
406 sition i+1 . rindex_opt s c is equivalent to rindex_from s (length s -
407 1) c .
408
409
410 Since 4.05
411
412
413 Raises Invalid_argument if i+1 is not a valid position in s .
414
415
416
417 val contains : bytes -> char -> bool
418
419
420 contains s c tests if byte c appears in s .
421
422
423
424 val contains_from : bytes -> int -> char -> bool
425
426
427 contains_from s start c tests if byte c appears in s after position
428 start . contains s c is equivalent to contains_from
429 s 0 c .
430
431
432 Raises Invalid_argument if start is not a valid position in s .
433
434
435
436 val rcontains_from : bytes -> int -> char -> bool
437
438
439 rcontains_from s stop c tests if byte c appears in s before position
440 stop+1 .
441
442
443 Raises Invalid_argument if stop < 0 or stop+1 is not a valid position
444 in s .
445
446
447
448 val uppercase : bytes -> bytes
449
450 Deprecated. Functions operating on Latin-1 character set are depre‐
451 cated.
452
453
454 Return a copy of the argument, with all lowercase letters translated to
455 uppercase, including accented letters of the ISO Latin-1 (8859-1) char‐
456 acter set.
457
458
459
460 val lowercase : bytes -> bytes
461
462 Deprecated. Functions operating on Latin-1 character set are depre‐
463 cated.
464
465
466 Return a copy of the argument, with all uppercase letters translated to
467 lowercase, including accented letters of the ISO Latin-1 (8859-1) char‐
468 acter set.
469
470
471
472 val capitalize : bytes -> bytes
473
474 Deprecated. Functions operating on Latin-1 character set are depre‐
475 cated.
476
477
478 Return a copy of the argument, with the first character set to upper‐
479 case, using the ISO Latin-1 (8859-1) character set.
480
481
482
483 val uncapitalize : bytes -> bytes
484
485 Deprecated. Functions operating on Latin-1 character set are depre‐
486 cated.
487
488
489 Return a copy of the argument, with the first character set to lower‐
490 case, using the ISO Latin-1 (8859-1) character set.
491
492
493
494 val uppercase_ascii : bytes -> bytes
495
496 Return a copy of the argument, with all lowercase letters translated to
497 uppercase, using the US-ASCII character set.
498
499
500 Since 4.05.0
501
502
503
504 val lowercase_ascii : bytes -> bytes
505
506 Return a copy of the argument, with all uppercase letters translated to
507 lowercase, using the US-ASCII character set.
508
509
510 Since 4.05.0
511
512
513
514 val capitalize_ascii : bytes -> bytes
515
516 Return a copy of the argument, with the first character set to upper‐
517 case, using the US-ASCII character set.
518
519
520 Since 4.05.0
521
522
523
524 val uncapitalize_ascii : bytes -> bytes
525
526 Return a copy of the argument, with the first character set to lower‐
527 case, using the US-ASCII character set.
528
529
530 Since 4.05.0
531
532
533 type t = bytes
534
535
536 An alias for the type of byte sequences.
537
538
539
540 val compare : t -> t -> int
541
542 The comparison function for byte sequences, with the same specification
543 as compare . Along with the type t , this function compare allows the
544 module Bytes to be passed as argument to the functors Set.Make and
545 Map.Make .
546
547
548
549 val equal : t -> t -> bool
550
551 The equality function for byte sequences.
552
553
554 Since 4.05.0
555
556
557
558 val starts_with : prefix:bytes -> bytes -> bool
559
560
561 starts_with ~ prefix s is true if and only if s starts with prefix .
562
563
564 Since 4.13.0
565
566
567
568 val ends_with : suffix:bytes -> bytes -> bool
569
570
571 ends_with suffix s is true if and only if s ends with suffix .
572
573
574 Since 4.13.0
575
576
577
578
579 Unsafe conversions (for advanced users)
580 This section describes unsafe, low-level conversion functions between
581 bytes and string . They do not copy the internal data; used improperly,
582 they can break the immutability invariant on strings provided by the
583 -safe-string option. They are available for expert library authors, but
584 for most purposes you should use the always-correct BytesLa‐
585 bels.to_string and BytesLabels.of_string instead.
586
587 val unsafe_to_string : bytes -> string
588
589 Unsafely convert a byte sequence into a string.
590
591 To reason about the use of unsafe_to_string , it is convenient to con‐
592 sider an "ownership" discipline. A piece of code that manipulates some
593 data "owns" it; there are several disjoint ownership modes, including:
594
595 -Unique ownership: the data may be accessed and mutated
596
597 -Shared ownership: the data has several owners, that may only access
598 it, not mutate it.
599
600 Unique ownership is linear: passing the data to another piece of code
601 means giving up ownership (we cannot write the data again). A unique
602 owner may decide to make the data shared (giving up mutation rights on
603 it), but shared data may not become uniquely-owned again.
604
605
606 unsafe_to_string s can only be used when the caller owns the byte se‐
607 quence s -- either uniquely or as shared immutable data. The caller
608 gives up ownership of s , and gains ownership of the returned string.
609
610 There are two valid use-cases that respect this ownership discipline:
611
612 1. Creating a string by initializing and mutating a byte sequence that
613 is never changed after initialization is performed.
614
615
616 let string_init len f : string =
617 let s = Bytes.create len in
618 for i = 0 to len - 1 do Bytes.set s i (f i) done;
619 Bytes.unsafe_to_string s
620
621
622 This function is safe because the byte sequence s will never be ac‐
623 cessed or mutated after unsafe_to_string is called. The string_init
624 code gives up ownership of s , and returns the ownership of the result‐
625 ing string to its caller.
626
627 Note that it would be unsafe if s was passed as an additional parameter
628 to the function f as it could escape this way and be mutated in the fu‐
629 ture -- string_init would give up ownership of s to pass it to f , and
630 could not call unsafe_to_string safely.
631
632 We have provided the String.init , String.map and String.mapi functions
633 to cover most cases of building new strings. You should prefer those
634 over to_string or unsafe_to_string whenever applicable.
635
636 2. Temporarily giving ownership of a byte sequence to a function that
637 expects a uniquely owned string and returns ownership back, so that we
638 can mutate the sequence again after the call ended.
639
640
641 let bytes_length (s : bytes) =
642 String.length (Bytes.unsafe_to_string s)
643
644
645 In this use-case, we do not promise that s will never be mutated after
646 the call to bytes_length s . The String.length function temporarily
647 borrows unique ownership of the byte sequence (and sees it as a string
648 ), but returns this ownership back to the caller, which may assume that
649 s is still a valid byte sequence after the call. Note that this is only
650 correct because we know that String.length does not capture its argu‐
651 ment -- it could escape by a side-channel such as a memoization combi‐
652 nator.
653
654 The caller may not mutate s while the string is borrowed (it has tempo‐
655 rarily given up ownership). This affects concurrent programs, but also
656 higher-order functions: if String.length returned a closure to be
657 called later, s should not be mutated until this closure is fully ap‐
658 plied and returns ownership.
659
660
661
662 val unsafe_of_string : string -> bytes
663
664 Unsafely convert a shared string to a byte sequence that should not be
665 mutated.
666
667 The same ownership discipline that makes unsafe_to_string correct ap‐
668 plies to unsafe_of_string : you may use it if you were the owner of the
669 string value, and you will own the return bytes in the same mode.
670
671 In practice, unique ownership of string values is extremely difficult
672 to reason about correctly. You should always assume strings are shared,
673 never uniquely owned.
674
675 For example, string literals are implicitly shared by the compiler, so
676 you never uniquely own them.
677
678
679 let incorrect = Bytes.unsafe_of_string "hello"
680 let s = Bytes.of_string "hello"
681
682
683 The first declaration is incorrect, because the string literal "hello"
684 could be shared by the compiler with other parts of the program, and
685 mutating incorrect is a bug. You must always use the second version,
686 which performs a copy and is thus correct.
687
688 Assuming unique ownership of strings that are not string literals, but
689 are (partly) built from string literals, is also incorrect. For exam‐
690 ple, mutating unsafe_of_string ("foo" ^ s) could mutate the shared
691 string "foo" -- assuming a rope-like representation of strings. More
692 generally, functions operating on strings will assume shared ownership,
693 they do not preserve unique ownership. It is thus incorrect to assume
694 unique ownership of the result of unsafe_of_string .
695
696 The only case we have reasonable confidence is safe is if the produced
697 bytes is shared -- used as an immutable byte sequence. This is possibly
698 useful for incremental migration of low-level programs that manipulate
699 immutable sequences of bytes (for example Marshal.from_bytes ) and pre‐
700 viously used the string type for this purpose.
701
702
703
704 val split_on_char : sep:char -> bytes -> bytes list
705
706
707 split_on_char sep s returns the list of all (possibly empty) subse‐
708 quences of s that are delimited by the sep character.
709
710 The function's output is specified by the following invariants:
711
712
713 -The list is not empty.
714
715 -Concatenating its elements using sep as a separator returns a byte se‐
716 quence equal to the input ( Bytes.concat (Bytes.make 1 sep)
717 (Bytes.split_on_char sep s) = s ).
718
719 -No byte sequence in the result contains the sep character.
720
721
722
723 Since 4.13.0
724
725
726
727
728 Iterators
729 val to_seq : t -> char Seq.t
730
731 Iterate on the string, in increasing index order. Modifications of the
732 string during iteration will be reflected in the sequence.
733
734
735 Since 4.07
736
737
738
739 val to_seqi : t -> (int * char) Seq.t
740
741 Iterate on the string, in increasing order, yielding indices along
742 chars
743
744
745 Since 4.07
746
747
748
749 val of_seq : char Seq.t -> t
750
751 Create a string from the generator
752
753
754 Since 4.07
755
756
757
758
759 Binary encoding/decoding of integers
760 The functions in this section binary encode and decode integers to and
761 from byte sequences.
762
763 All following functions raise Invalid_argument if the space needed at
764 index i to decode or encode the integer is not available.
765
766 Little-endian (resp. big-endian) encoding means that least (resp. most)
767 significant bytes are stored first. Big-endian is also known as net‐
768 work byte order. Native-endian encoding is either little-endian or
769 big-endian depending on Sys.big_endian .
770
771 32-bit and 64-bit integers are represented by the int32 and int64
772 types, which can be interpreted either as signed or unsigned numbers.
773
774 8-bit and 16-bit integers are represented by the int type, which has
775 more bits than the binary encoding. These extra bits are handled as
776 follows:
777
778 -Functions that decode signed (resp. unsigned) 8-bit or 16-bit integers
779 represented by int values sign-extend (resp. zero-extend) their result.
780
781 -Functions that encode 8-bit or 16-bit integers represented by int val‐
782 ues truncate their input to their least significant bytes.
783
784
785 val get_uint8 : bytes -> int -> int
786
787
788 get_uint8 b i is b 's unsigned 8-bit integer starting at byte index i .
789
790
791 Since 4.08
792
793
794
795 val get_int8 : bytes -> int -> int
796
797
798 get_int8 b i is b 's signed 8-bit integer starting at byte index i .
799
800
801 Since 4.08
802
803
804
805 val get_uint16_ne : bytes -> int -> int
806
807
808 get_uint16_ne b i is b 's native-endian unsigned 16-bit integer start‐
809 ing at byte index i .
810
811
812 Since 4.08
813
814
815
816 val get_uint16_be : bytes -> int -> int
817
818
819 get_uint16_be b i is b 's big-endian unsigned 16-bit integer starting
820 at byte index i .
821
822
823 Since 4.08
824
825
826
827 val get_uint16_le : bytes -> int -> int
828
829
830 get_uint16_le b i is b 's little-endian unsigned 16-bit integer start‐
831 ing at byte index i .
832
833
834 Since 4.08
835
836
837
838 val get_int16_ne : bytes -> int -> int
839
840
841 get_int16_ne b i is b 's native-endian signed 16-bit integer starting
842 at byte index i .
843
844
845 Since 4.08
846
847
848
849 val get_int16_be : bytes -> int -> int
850
851
852 get_int16_be b i is b 's big-endian signed 16-bit integer starting at
853 byte index i .
854
855
856 Since 4.08
857
858
859
860 val get_int16_le : bytes -> int -> int
861
862
863 get_int16_le b i is b 's little-endian signed 16-bit integer starting
864 at byte index i .
865
866
867 Since 4.08
868
869
870
871 val get_int32_ne : bytes -> int -> int32
872
873
874 get_int32_ne b i is b 's native-endian 32-bit integer starting at byte
875 index i .
876
877
878 Since 4.08
879
880
881
882 val get_int32_be : bytes -> int -> int32
883
884
885 get_int32_be b i is b 's big-endian 32-bit integer starting at byte in‐
886 dex i .
887
888
889 Since 4.08
890
891
892
893 val get_int32_le : bytes -> int -> int32
894
895
896 get_int32_le b i is b 's little-endian 32-bit integer starting at byte
897 index i .
898
899
900 Since 4.08
901
902
903
904 val get_int64_ne : bytes -> int -> int64
905
906
907 get_int64_ne b i is b 's native-endian 64-bit integer starting at byte
908 index i .
909
910
911 Since 4.08
912
913
914
915 val get_int64_be : bytes -> int -> int64
916
917
918 get_int64_be b i is b 's big-endian 64-bit integer starting at byte in‐
919 dex i .
920
921
922 Since 4.08
923
924
925
926 val get_int64_le : bytes -> int -> int64
927
928
929 get_int64_le b i is b 's little-endian 64-bit integer starting at byte
930 index i .
931
932
933 Since 4.08
934
935
936
937 val set_uint8 : bytes -> int -> int -> unit
938
939
940 set_uint8 b i v sets b 's unsigned 8-bit integer starting at byte index
941 i to v .
942
943
944 Since 4.08
945
946
947
948 val set_int8 : bytes -> int -> int -> unit
949
950
951 set_int8 b i v sets b 's signed 8-bit integer starting at byte index i
952 to v .
953
954
955 Since 4.08
956
957
958
959 val set_uint16_ne : bytes -> int -> int -> unit
960
961
962 set_uint16_ne b i v sets b 's native-endian unsigned 16-bit integer
963 starting at byte index i to v .
964
965
966 Since 4.08
967
968
969
970 val set_uint16_be : bytes -> int -> int -> unit
971
972
973 set_uint16_be b i v sets b 's big-endian unsigned 16-bit integer start‐
974 ing at byte index i to v .
975
976
977 Since 4.08
978
979
980
981 val set_uint16_le : bytes -> int -> int -> unit
982
983
984 set_uint16_le b i v sets b 's little-endian unsigned 16-bit integer
985 starting at byte index i to v .
986
987
988 Since 4.08
989
990
991
992 val set_int16_ne : bytes -> int -> int -> unit
993
994
995 set_int16_ne b i v sets b 's native-endian signed 16-bit integer start‐
996 ing at byte index i to v .
997
998
999 Since 4.08
1000
1001
1002
1003 val set_int16_be : bytes -> int -> int -> unit
1004
1005
1006 set_int16_be b i v sets b 's big-endian signed 16-bit integer starting
1007 at byte index i to v .
1008
1009
1010 Since 4.08
1011
1012
1013
1014 val set_int16_le : bytes -> int -> int -> unit
1015
1016
1017 set_int16_le b i v sets b 's little-endian signed 16-bit integer start‐
1018 ing at byte index i to v .
1019
1020
1021 Since 4.08
1022
1023
1024
1025 val set_int32_ne : bytes -> int -> int32 -> unit
1026
1027
1028 set_int32_ne b i v sets b 's native-endian 32-bit integer starting at
1029 byte index i to v .
1030
1031
1032 Since 4.08
1033
1034
1035
1036 val set_int32_be : bytes -> int -> int32 -> unit
1037
1038
1039 set_int32_be b i v sets b 's big-endian 32-bit integer starting at byte
1040 index i to v .
1041
1042
1043 Since 4.08
1044
1045
1046
1047 val set_int32_le : bytes -> int -> int32 -> unit
1048
1049
1050 set_int32_le b i v sets b 's little-endian 32-bit integer starting at
1051 byte index i to v .
1052
1053
1054 Since 4.08
1055
1056
1057
1058 val set_int64_ne : bytes -> int -> int64 -> unit
1059
1060
1061 set_int64_ne b i v sets b 's native-endian 64-bit integer starting at
1062 byte index i to v .
1063
1064
1065 Since 4.08
1066
1067
1068
1069 val set_int64_be : bytes -> int -> int64 -> unit
1070
1071
1072 set_int64_be b i v sets b 's big-endian 64-bit integer starting at byte
1073 index i to v .
1074
1075
1076 Since 4.08
1077
1078
1079
1080 val set_int64_le : bytes -> int -> int64 -> unit
1081
1082
1083 set_int64_le b i v sets b 's little-endian 64-bit integer starting at
1084 byte index i to v .
1085
1086
1087 Since 4.08
1088
1089
1090
1091
1092
1093OCamldoc 2022-02-04 Stdlib.BytesLabels(3)