zm'55.5.0+dev0-2025-04-28/+BytesLabels&length@%bytes@@@#int@@@@@-%bytes_lengthAA @@@<../../stdlib/bytesLabels.mliy  y  @@@+BytesLabels@@@#get@@@@@@@@$char@@@@@@@/%bytes_safe_getBA$@@@@$| ~ ~%| ~ @@#A@@#set@@@@@@A@@@@$@@@$unit@@@@@@@@@/%bytes_safe_setCAM@@@@@NA 8 8OA 8 w@@MB@@&create@d@@@o@@@@@1caml_create_bytesAAh@@@gF  hF  E@@fC@@$make@}@@@@`@@@@@@@@@@@K  K  -@@D@@$init@@@@!f@@@@@@@@@@@@@@@@@P  P  @@E@@%empty@@@@VV@@F@@$copy@@@@@@@@@@YY2@@G@@)of_string@&string@@@@@@@@@]]@@H@@)to_string@@@@@@@@@@aa @@I@@#sub@@@@#pos@@@#len@@@)@@@@@@@@@@ezzez@@J@@*sub_string@9@@@#pos<@@@#lenE@@@i@@@@@@@@@@DlEl@@CK@@&extend@`@@@$leftc@@@%rightl@@@w@@@@@@@@@@ko&&lo&Z@@jL@@$fill@@@@#pos@@@#len@@@@v@@@R@@@@@@@@@@@@y##y#Y@@M@@$blit #src@@@'src_pos@@@#dst@@@'dst_pos@@@#len@@@@@@@@@@@@@@@@@$$qz@@N@@+blit_string!#src @@@'src_pos@@@#dst@@@'dst_pos@@@#len@@@@@@@@@@@@@@@@@ZZ@@O@@&concat"#sep-@@@@$list:@@@@@@@@@@@@@@@46656c@@3P@@#cat#@P @@@@W @@@\ @@@@@@@@P}}Q}@@OQ@@$iter$!f@F @@@" @@@@@ @|@@@ .@@@ @@ @@ @u}}v}@@tR@@%iteri%!f@@@@@r@@@N@@@@@@@@@@@Z@@@@@@@@OOO@@S@@#map&!f@@@@@@@@@@@@@@@@@@@@@@@@T@@$mapi'!f@@@@@@@@@@@ @@!@@"@@@@#@@@$@@%@@&@2@@U@@)fold_left(!f@#acc@0A@'@@@@( @@)@@*$init@%@@@+@@,@@-@@.@5@@V@@*fold_right)!f@ @@@1@#acc@:A@2@@3@@4@H!@@@5$init@@6@@7@@8@@A @@?W@@'for_all*!f@6"@@@;$bool#@@@<@@=@m$@@@> %@@@?@@@@@A@f  g  @@eX@@&exists+!f@\&@@@B&'@@@C@@D@(@@@E2)@@@F@@G@@H@!=!=!=!k@@Y@@$trim,@*@@@I+@@@J@@K@!!!!@@Z@@'escaped-@,@@@L-@@@M@@N@""""@@[@@%index.@.@@@O@/@@@P0@@@Q@@R@@S@$4$4$4$T@@\@@)index_opt/@1@@@T@2@@@U&optionL3@@@V@@@X@@Y@@Z@$$$%@@]@@&rindex0@4@@@[@5@@@\6@@@]@@^@@_@%%%%@@^@@*rindex_opt1@,7@@@`@ 8@@@a?69@@@b@@@d@@e@@f@1&E&E2&E&p@@0_@@*index_from2@M:@@@g@N;@@@h@1<@@@iZ=@@@j@@k@@l@@m@T''U''.@@S`@@.index_from_opt3@p>@@@n@q?@@@o@T@@@@pA@@@q@@@s@@t@@u@@v@|(^(^}(^(@@{a@@+rindex_from4@B@@@w@C@@@x@|D@@@yE@@@z@@{@@|@@}@)))*@@b@@/rindex_from_opt5@F@@@~@G@@@@H@@@ՠI@@@@@@@@@@@@@+K+K+K+@@c@@(contains6@J@@@@K@@@L@@@@@@@@ ,, ,,@@d@@-contains_from7@M@@@@N@@@@O@@@P@@@@@@@@@@-7-7-7-g@@e@@.rcontains_from8@"Q@@@@#R@@@@S@@@T@@@@@@@@@@).J.J*.J.{@@(f@@/uppercase_ascii9@EU@@@JV@@@@@@>/7/7?/7/[@@=g@@/lowercase_ascii:@ZW@@@_X@@@@@@S!//T!/0@@Rh@@0capitalize_ascii;@oY@@@tZ@@@@@@h&00i&00@@gi@@2uncapitalize_ascii<@[@@@\@@@@@@}+1K1K~+1K1r@@|j@@!t=A;@@@A]@@@@@@@011012@@@@k@A@'compare>@+BytesLabels^!t@@@@+BytesLabels_!t@@@`@@@@@@@@329293292S@@l@@%equal?@+BytesLabelsa!t@@@@+BytesLabelsb!t@@@xc@@@@@@@@93X3X93X3q@@m@@+starts_with@&prefixd@@@@e@@@f@@@@@@@@=33>34@@n@@)ends_withA&suffix g@@@@h@@@i@@@@@@@@ D4~4~E44@@ o@@0unsafe_to_stringB@)j@@@Gk@@@@@@"T66#T67 @@!p@@0unsafe_of_stringC@Wl@@@Cm@@@@@@7CC8CC@@6q@@-split_on_charD#sep+n@@@@\o@@@-qfp@@@@@@@@@@@[KK\KK5@@Zr@@&to_seq@+BytesLabelsr!t@@@&Stdlibt#Seq!t_s@@@ @@@ @@ @~MMMM@@}s@@'to_seqi@+BytesLabelsu!t@@@ &Stdlibx#Seq!t@v@@@ @w@@@ @@ @@@ @@ @NANANANf@@t@@&of_seq@&Stdlibz#Seq!ty@@@ @@@ +BytesLabels{!t@@@ @@ @NNNN@@u@@/get_utf_8_uchar@+BytesLabels|!t@@@ @}@@@ &Stdlib~%Uchar*utf_decode@@@ @@ @@ @OtOtOtO@@v@@/set_utf_8_uchar@+BytesLabels!t@@@ @@@@ @&Stdlib%Uchar!t@@@ $@@@ @@ @@ @@ @OOOP)@@w@@.is_valid_utf_8@+BytesLabels!t@@@ @@@ @@ @6QVQV7QVQt@@5x@@2get_utf_16be_uchar@+BytesLabels!t@@@ @V@@@ &Stdlib%Uchar*utf_decode@@@ @@ @@ @ZQQ[QR@@Yy@@2set_utf_16be_uchar@+BytesLabels!t@@@ @z@@@ @&Stdlib%Uchar!t@@@ @@@ @@ @@ @@ @RxRxRxR@@z@@1is_valid_utf_16be@+BytesLabels!t@@@ D@@@ @@ @ SS SS@@{@@2get_utf_16le_uchar@+BytesLabels!t@@@ @@@@ &Stdlib%Uchar*utf_decode@@@ @@ @@ @T{T{T{T@@|@@2set_utf_16le_uchar@+BytesLabels!t@@@ @@@@ @&Stdlib%Uchar!t@@@ @@@ @@ @@ @@ @U U U U<@@}@@1is_valid_utf_16le@+BytesLabels!t@@@ @@@ @@ @VoVoVoV@@~@@)get_uint8@ @@@ @!@@@ &@@@ @@ @@ @ @[[!@[[@@@@(get_int8@<@@@ @=@@@ B@@@ @@ @@ @<E\/\/=E\/\Q@@;@@@-get_uint16_ne@X@@@ @Y@@@ ^@@@ @@ @@ @XJ\\YJ\\@@WA@@-get_uint16_be@t@@@ @u@@@ z@@@ @@ @@ @tP]V]VuP]V]}@@sB@@-get_uint16_le@@@@ @@@@ @@@ @@ @@ @V]]V]^@@C@@,get_int16_ne@@@@ @@@@ @@@ @@ @@ @\^^\^^@@D@@,get_int16_be@@@@ @@@@ @@@ @@ @@ @b_8_8b_8_^@@E@@,get_int16_le@@@@ @@@@ @@@ @@ @@ @h__h__@@F@@,get_int32_ne@ @@@ @ @@@ %int32@@@ @@ @@ @ n`s`s n`s`@@ G@@,get_int32_be@ @@@ @ @@@ @@@ @@ @@ @ ta a  ta a5@@ H@@,get_int32_le@ 9@@@ @ :@@@ 9@@@ @@ @@ @ 9zaa :zaa@@ 8I@@,get_int64_ne@ U@@@ @ V@@@ %int64@@@ @@ @@ @ Vb>b> Wb>bf@@ UJ@@,get_int64_be@ r@@@ @ s@@@ @@@ @@ @@ @ rbb sbc@@ qK@@,get_int64_le@ @@@ @ @@@ 9@@@ @@ @@ @ coco coc@@ L@@)set_uint8@ @@@ @ @@@ @ @@@  j@@@ @@ @@ @@ @ d d  d d4@@ M@@(set_int8@ @@@ @ @@@ @ @@@ ! @@@ "@@ #@@ $@@ %@ dd dd@@ N@@-set_uint16_ne@ @@@ &@ @@@ '@ @@@ ( @@@ )@@ *@@ +@@ ,@ eCeC eCer@@ O@@-set_uint16_be@ @@@ -@ @@@ .@ @@@ / @@@ 0@@ 1@@ 2@@ 3@ ee ef(@@ P@@-set_uint16_le@ 6@@@ 4@ 7@@@ 5@ >@@@ 6 @@@ 7@@ 8@@ 9@@ :@ =ff >ff@@ <Q@@,set_int16_ne@ Y@@@ ;@ Z@@@ <@ a@@@ = @@@ >@@ ?@@ @@@ A@ `gbgb agbg@@ _R@@,set_int16_be@ |@@@ B@ }@@@ C@ @@@ D <@@@ E@@ F@@ G@@ H@ hh hhB@@ S@@,set_int16_le@ @@@ I@ @@@ J@ @@@ K _@@@ L@@ M@@ N@@ O@ hh hh@@ T@@,set_int32_ne@ @@@ P@ @@@ Q@@@@ R @@@ S@@ T@@ U@@ V@ iuiu iui@@ U@@,set_int32_be@ @@@ W@ @@@ X@@@@ Y @@@ Z@@ [@@ \@@ ]@ j"j" j"jR@@ V@@,set_int32_le@ @@@ ^@ @@@ _@ @@@ ` @@@ a@@ b@@ c@@ d@ jj jj@@ W@@,set_int64_ne@ +@@@ e@ ,@@@ f@@@@ g @@@ h@@ i@@ j@@ k@ 2kyky 3kyk@@ 1X@@,set_int64_be@ N@@@ l@ O@@@ m@@@@ n @@@ o@@ p@@ q@@ r@ Ul&l& Vl&lV@@ TY@@,set_int64_le@ q@@@ s@ r@@@ t@@@@ u 1@@@ v@@ w@@ x@@ y@ xll ylm@@ wZ@@*unsafe_get@ @@@ z@ @@@ { v@@@ |@@ }@@ ~1%bytes_unsafe_getBA @@@@ -xx -xx@@ [@@*unsafe_set@ @@@ @ @@@ @ @@@  u@@@ @@ @@ @@ 1%bytes_unsafe_setCA @@@@@ .xx .xy!@@ \@@+unsafe_blit#src @@@ 'src_pos @@@ #dst @@@ 'dst_pos @@@ #len @@@  @@@ @@ @@ @@ @@ @@ /caml_blit_bytesE@ @@@@@@@ /y"y" 1y~y@'noalloc 1y~y 1y~y@@ 1y~y @@ ]@@2unsafe_blit_string#src F@@@ 'src_pos 0@@@ #dst ?@@@ 'dst_pos B @@@ #len K @@@   @@@ @@ @@ @@ @@ @@ 0caml_blit_stringE@ O@@@@@@@ R2yy S4zz2@'noalloc Y4zz* Z4zz1@@ ]4zz' @@ [^@@+unsafe_fill@ x @@@ #pos { @@@ #len @@@ @ g@@@  C@@@ @@ @@ @@ @@ /caml_fill_bytesD@ @@@@@@ 5z3z3 6zJz@'noalloc 6zJz 6zJz@@ 6zJz @@ _@@-unsafe_escape@ @@@  @@@ @@ @ 8zz 8zz@@ `@@@39Byte sequence operations.@ A byte sequence is a mutable data structure that contains a fixed-length sequence of bytes. Each byte can be indexed in constant time for reading or writing.@: Given a byte sequence !s+ of length !l?, we can access each of the !l* bytes of !s 4 via its index in the sequence. Indexes start at !0 %, and we will call an index valid in !s ! if it falls within the range )[0...l-1] (inclusive). A position is the point between two bytes or at the beginning or end of the sequence. We call a position valid in !s> if it falls within the range '[0...l] - (inclusive). Note that the byte at index !n9 is between positions !n% and #n+1!.@3 Two parameters %start% and #len + are said to designate a valid range of !s$ if (len >= 0% and %start% and )start+len; are valid positions in !s!.@ B Byte sequences can be modified in place, for instance via the #set( and $blit 9 functions described below. See also strings (module &String@@ P), which are almost the same data structure, but cannot be modified in place.@ , Bytes are represented by the OCaml type $char!.@ J The labeled version of this module can be used as described in the )StdLabels@@( module.@@@@$4.02@@@@@@@A<../../stdlib/bytesLabels.mli2BytesLabels.length3 4Return the length (number of bytes) of the argument.@@@@@@@@@@@@ @  @@@@ v/BytesLabels.get3'get s n; returns the byte at index !n- in argument !s!.@@@@@@@@0Invalid_argument#if !n9 is not a valid index in !s!.@@@@@ @1 @4 @@@@ /BytesLabels.set3)set s n c* modifies !s ' in place, replacing the byte at index !n* with !c!.@@@@@@@@0Invalid_argument#if !n9 is not a valid index in !s!.@@@@@ @j @m @p @@@@ 2BytesLabels.create3(create n ' returns a new byte sequence of length !n A. The sequence is uninitialized and contains arbitrary bytes.@@@@@@@@0Invalid_argument#if %n < 0$ or $n > 5Sys.max_string_length@@!.@@@@@ @ @@@@ 0BytesLabels.make3(make n c ' returns a new byte sequence of length !n;, filled with the byte !c!.@@@@@@@@0Invalid_argument#if %n < 0$ or $n > 5Sys.max_string_length@@!.@@@@@ @ @ @@@@ Š0BytesLabels.init3(init n f ) returns a fresh byte sequence of length !n5, with character !i> initialized to the result of #f i ! (in increasing index order).@@@@@@@@0Invalid_argument#if %n < 0$ or $n > 5Sys.max_string_length@@!.@@@@@ @  @  @@@@ ܠ1BytesLabels.empty3:A byte sequence of size 0.@@@@@@@@@@@@ @@@@ ڠ0BytesLabels.copy3 LReturn a new byte sequence that contains the same bytes as the argument.@@@@@@@@@@@@ @* @@@@ Ԡ5BytesLabels.of_string3 PReturn a new byte sequence that contains the same bytes as the given string.@@@@@@@@@@@@ @9 @@@@ ͠5BytesLabels.to_string3 PReturn a new string that contains the same bytes as the given byte sequence.@@@@@@@@@@@@ @H @@@@ Ǡ/BytesLabels.sub3/sub s ~pos ~len ' returns a new byte sequence of length #len $, containing the subsequence of !s9 that starts at position #pos4 and has length #len!.@@@@@@@@0Invalid_argument#if #pos% and #len ' do not designate a valid range of !s!.@@@@@ @ @  @  @@@@ 蠕6BytesLabels.sub_string3(Same as QD@ 0 but return a string instead of a byte sequence.@@@@@@@@@@@@ @ @  @  @@@@ ܠ2BytesLabels.extend35extend s ~left ~right < returns a new byte sequence that contains the bytes of !s', with $left ' uninitialized bytes prepended and %right ( uninitialized bytes appended to it. If $left$ or %right b is negative, then bytes are removed (instead of appended) from the corresponding side of !s!.@@@@34.05 in BytesLabels@@@0Invalid_argument 4if the result length is negative or longer than 5Sys.max_string_length@@' bytes.@@@@@@@ @@@@@ 0BytesLabels.fill32fill s ~pos ~len c* modifies !s5 in place, replacing #len5 characters with !c., starting at #pos!.@@@@@@@@0Invalid_argument#if #pos% and #len ' do not designate a valid range of !s!.@@@@@3@74@/.@)(@@$@@@@0BytesLabels.blit3 %blit ~src ~src_pos ~dst ~dst_pos ~len( copies #len> bytes from byte sequence #src4, starting at index 'src_pos3, to byte sequence #dst8, starting at index 'dst_pos=. It works correctly even if #src% and #dst V are the same byte sequence, and the source and destination intervals overlap.@@@@@@@@0Invalid_argument#if 'src_pos% and #len ' do not designate a valid range of #src(, or if 'dst_pos% and #len ' do not designate a valid range of #dst!.@@@@@t@ts@nm@hg@ba@\[@@@@S7BytesLabels.blit_string3 ,blit_string ~src ~src_pos ~dst ~dst_pos ~len( copies #len7 bytes from string #src4, starting at index 'src_pos3, to byte sequence #dst8, starting at index 'dst_pos!.@@@@34.05 in BytesLabels@@@0Invalid_argument#if 'src_pos% and #len ' do not designate a valid range of #src(, or if 'dst_pos% and #len ' do not designate a valid range of #dst!.@@@@@@@@@@@@@@2BytesLabels.concat3.concat ~sep sl ) concatenates the list of byte sequences "sl ,, inserting the separator byte sequence #sep A between each, and returns the result as a new byte sequence.@@@@@@@@0Invalid_argument !if the result is longer than 5Sys.max_string_length@@' bytes.@@@@@@@G@@@@/BytesLabels.cat3)cat s1 s2. concatenates "s1% and "s2 3 and returns the result as a new byte sequence.@@@@34.05 in BytesLabels@@@0Invalid_argument !if the result is longer than 5Sys.max_string_length@@' bytes.@@@@@@s@v@@@@0BytesLabels.iter3)iter ~f s2 applies function !f= in turn to all the bytes of !s:. It is equivalent to ?f (get s 0); f (get s 1); ...; f (get s (length s - 1)); ()!.@@@@@@@@@@@@@@@@@@1BytesLabels.iteri3(Same as 0D@ x, but the function is applied to the index of the byte as first argument and the byte itself as second argument.@@@@@@@@@@@@@@@@@@/BytesLabels.map3(map ~f s2 applies function !f= in turn to all the bytes of !s u (in increasing index order) and stores the resulting bytes in a new sequence that is returned as the result.@@@@@@@@@@@@@@@@@@0BytesLabels.mapi3)mapi ~f s' calls !f8 with each character of !s and its index (in increasing index order) and stores the resulting bytes in a new sequence that is returned as the result.@@@@@@@@@@@@@@@@@@z5BytesLabels.fold_left3/fold_left f x s. computes 7f (... (f (f x (get s 0)) (get s 1)) ...) (get s (n-1)),, where !n2 is the length of !s!.@@@@$4.13@@@@@@@@@@#@@@@6BytesLabels.fold_right30fold_right f s x. computes 8f (get s 0) (f (get s 1) ( ... (f (get s (n-1)) x) ...)),, where !n2 is the length of !s!.@@@@$4.13@@@@@@@@@L@@@@@3BytesLabels.for_all3+for_all p s= checks if all characters in !s7 satisfy the predicate !p!.@@@@$4.13@@@@@@@@@r@@@@2BytesLabels.exists3*exists p s % checks if at least one character of !s= satisfies the predicate !p!.@@@@$4.13@@@@@@@@@@@@@0BytesLabels.trim3 Return a copy of the argument, without leading and trailing whitespace. The bytes regarded as whitespace are the ASCII characters #' '", &'\012'", $'\n'", $'\r'&, and $'\t'!.@@@@@@@@@@@@@@@@@3BytesLabels.escaped3 Return a copy of the argument, with special characters represented by escape sequences, following the lexical conventions of OCaml. All characters outside the ASCII printable range (32..126) are escaped, as well as backslash and double-quote.@@@@@@@@0Invalid_argument !if the result is longer than 5Sys.max_string_length@@' bytes.@@@@@@@@@@1BytesLabels.index3)index s c 3 returns the index of the first occurrence of byte !c( in !s!.@@@@@@@@)Not_found#if !c3 does not occur in !s!.@@@@@@ @@@@@5BytesLabels.index_opt3-index_opt s c 3 returns the index of the first occurrence of byte !c( in !s$ or $None$ if !c3 does not occur in !s!.@@@@$4.05@@@@@@@@B@E@@@@Ơ2BytesLabels.rindex3*rindex s c 2 returns the index of the last occurrence of byte !c( in !s!.@@@@@@@@)Not_found#if !c3 does not occur in !s!.@@@@@@u@x@@@@ݠ6BytesLabels.rindex_opt3.rindex_opt s c 2 returns the index of the last occurrence of byte !c( in !s$ or $None$ if !c3 does not occur in !s!.@@@@$4.05@@@@@@@@@@@@@6BytesLabels.index_from30index_from s i c 7 returns the index of the first occurrence of byte !c$ in !s0 after position !i#. )index s c6 is equivalent to 0index_from s 0 c!.@@@@@@@@0Invalid_argument#if !i< is not a valid position in !s!.@)Not_found#if !c3 does not occur in !s0 after position !i!.@@@@@=@>@ :@ 6@@@@.:BytesLabels.index_from_opt34index_from_opt s i c 7 returns the index of the first occurrence of byte !c$ in !s0 after position !i$ or $None$ if !c3 does not occur in !s4 after position !i&. -index_opt s c2 is equivalent to 4index_from_opt s 0 c!.@@@@$4.05@@@0Invalid_argument#if !i< is not a valid position in !s!.@@@@@|@i}@ly@ou@@@@h7BytesLabels.rindex_from31rindex_from s i c 6 returns the index of the last occurrence of byte !c$ in !s1 before position #i+1#. *rindex s c6 is equivalent to >rindex_from s (length s - 1) c!.@@@@@@@@0Invalid_argument#if #i+1< is not a valid position in !s!.@)Not_found#if !c3 does not occur in !s1 before position #i+1!.@@@@@@@@@@@@;BytesLabels.rindex_from_opt35rindex_from_opt s i c 6 returns the index of the last occurrence of byte !c$ in !s1 before position #i+1$ or $None$ if !c7 does not occur in !s1 before position #i+1#. .rindex_opt s c6 is equivalent to >rindex_from s (length s - 1) c!.@@@@$4.05@@@0Invalid_argument#if #i+1< is not a valid position in !s!.@@@@@@+@.@1@@@@ߠ4BytesLabels.contains3,contains s c/ tests if byte !c, appears in !s!.@@@@@@@@@@@@@O@R@@@@䠕9BytesLabels.contains_from37contains_from s start c/ tests if byte !c, appears in !s4 after position %start#. ,contains s c2 is equivalent to 7contains_from s 0 c!.@@@@@@@@0Invalid_argument#if %start< is not a valid position in !s!.@@@@@@@@@@@@ :BytesLabels.rcontains_from37rcontains_from s stop c/ tests if byte !c, appears in !s5 before position &stop+1!.@@@@@@@@0Invalid_argument#if (stop < 0$ or &stop+1 is not a valid position in !s!.@@@@@7@8@4@0@@@@(;BytesLabels.uppercase_ascii3 wReturn a copy of the argument, with all lowercase letters translated to uppercase, using the US-ASCII character set.@@@@$4.05@@@@@@@+@,@@@@$;BytesLabels.lowercase_ascii3 wReturn a copy of the argument, with all uppercase letters translated to lowercase, using the US-ASCII character set.@@@@$4.05@@@@@@@'@(@@@@ BytesLabels.uncapitalize_ascii3 nReturn a copy of the argument, with the first character set to lowercase, using the US-ASCII character set.@@@@$4.05@@@@@@@@  @@@@#-BytesLabels.t3 (An alias for the type of byte sequences.@@@@@@@@@@@@@@A@@@3BytesLabels.compare3 OThe comparison function for byte sequences, with the same specification as .Stdlib.compare@@7. Along with the type !t4, this function 'compare3 allows the module %Bytes . to be passed as argument to the functors (Set.Make@@% and (Map.Make@@!.@@@@@@@@@@@@<@b=@e6@@@@+1BytesLabels.equal3 )The equality function for byte sequences.@@@@$4.05@@@@@@@.@v/@y(@@@@7BytesLabels.starts_with3,starts_with )~prefix s$ is $true0 if and only if !s1 starts with &prefix!.@@@@$4.13@@@@@@@8@87@3@@@@+5BytesLabels.ends_with3*ends_with )~suffix s$ is $true0 if and only if !s+ ends with &suffix!.@@@@$4.13@@@@@@@F@FE@A@@@@9A&unsafe 'Unsafe conversions (for advanced users)@@ O This section describes unsafe, low-level conversion functions between %bytes% and &string . They do not copy the internal data; used improperly, they can break the immutability invariant on strings. They are available for expert library authors, but for most purposes you should use the always-correct D@) and ŐD@) instead.@ The caller may not mutate !s while the string is borrowed (it has temporarily given up ownership). This affects concurrent programs, but also higher-order functions: if -String.length@@ + returned a closure to be called later, !s T should not be mutated until this closure is fully applied and returns ownership.@@@@@@@@@@@@J@ K@@@@C) and previously used the &string7 type for this purpose.@@@@@@@@@@@@@ f@@@@9BytesLabels.split_on_char33split_on_char sep s > returns the list of all (possibly empty) subsequences of !s; that are delimited by the #sep3 character. If !s , is empty, the result is the singleton list '[empty]!.@ D The function's output is specified by the following invariants:@6The list is not empty.@ !Concatenating its elements using #sep B as a separator returns a byte sequence equal to the input ( EBytes.concat (Bytes.make 1 sep) (Bytes.split_on_char sep s) = s").@ ,No byte sequence in the result contains the #sep+ character.@@@@@@$4.13@@@@@@@@@ @@@@ԠA@)Iterators@@2BytesLabels.to_seq3 Iterate on the string, in increasing index order. Modifications of the string during iteration will be reflected in the sequence.@@@@$4.07@@@@@@@@ @@@@ɠ3BytesLabels.to_seqi3 HIterate on the string, in increasing order, yielding indices along chars@@@@$4.07@@@@@@@@ @@@@2BytesLabels.of_seq3 "Create a string from the generator@@@@$4.07@@@@@@@@ @@@@A#utf:UTF codecs and validations@@B%utf_8%UTF-8@@;BytesLabels.get_utf_8_uchar33get_utf_8_uchar b i % decodes an UTF-8 character at index !i( in !b!.@@@@@@@@@@@@@ $@ '@@@@;BytesLabels.set_utf_8_uchar35set_utf_8_uchar b i u/ UTF-8 encodes !u* at index !i$ in !b % and returns the number of bytes !n # that were written starting at !i%. If !n$ is !0 & there was not enough space to encode !u( at !i% and !b E was left untouched. Otherwise a new character can be encoded at %i + n!.@@@@@@@@@@@@@ {@ ~@ @@@@ؠ:BytesLabels.is_valid_utf_830is_valid_utf_8 b$ is $true0 if and only if !b? contains valid UTF-8 data.@@@@@@@@@@@@@ @@@@ޠB(utf_16be(UTF-16BE@@>BytesLabels.get_utf_16be_uchar36get_utf_16be_uchar b i , decodes an UTF-16BE character at index !i$ in !b!.@@@@@@@@@@@@@ @ @@@@䠕>BytesLabels.set_utf_16be_uchar38set_utf_16be_uchar b i u2 UTF-16BE encodes !u* at index !i$ in !b % and returns the number of bytes !n # that were written starting at !i%. If !n$ is !0 & there was not enough space to encode !u( at !i% and !b E was left untouched. Otherwise a new character can be encoded at %i + n!.@@@@@@@@@@@@*@ +@ $@ # @@@@=BytesLabels.is_valid_utf_16be33is_valid_utf_16be b$ is $true0 if and only if !b " contains valid UTF-16BE data.@@@@@@@@@@@@#@ A$@@@@B(utf_16le(UTF-16LE@@>BytesLabels.get_utf_16le_uchar36get_utf_16le_uchar b i , decodes an UTF-16LE character at index !i$ in !b!.@@@@@@@@@@@@2@ h3@ k,@@@@>BytesLabels.set_utf_16le_uchar38set_utf_16le_uchar b i u2 UTF-16LE encodes !u* at index !i$ in !b % and returns the number of bytes !n # that were written starting at !i%. If !n$ is !0 & there was not enough space to encode !u( at !i% and !b E was left untouched. Otherwise a new character can be encoded at %i + n!.@@@@@@@@@@@@e@ f@ _@ [@@@@N=BytesLabels.is_valid_utf_16le33is_valid_utf_16le b$ is $true0 if and only if !b " contains valid UTF-16LE data.@@@@@@@@@@@@^@ _@@@@TA@ $Binary encoding/decoding of integers@@ _The functions in this section binary encode and decode integers to and from byte sequences.@ # All following functions raise 0Invalid_argument " if the space needed at index !i 6 to decode or encode the integer is not available.@ Little-endian (resp. big-endian) encoding means that least (resp. most) significant bytes are stored first. Big-endian is also known as network byte order. Native-endian encoding is either little-endian or big-endian depending on .Sys.big_endian@@!.@ 7 32-bit and 64-bit integers are represented by the %int32) and %int64 J types, which can be interpreted either as signed or unsigned numbers.@ 6 8-bit and 16-bit integers are represented by the #int k type, which has more bits than the binary encoding. These extra bits are handled as follows: ]Functions that decode signed (resp. unsigned) 8-bit or 16-bit integers represented by #int < values sign-extend (resp. zero-extend) their result.@ EFunctions that encode 8-bit or 16-bit integers represented by #int E values truncate their input to their least significant bytes.@@@5BytesLabels.get_uint83-get_uint8 b i$ is !b 1's unsigned 8-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ Y@ \@@@@4BytesLabels.get_int83,get_int8 b i$ is !b /'s signed 8-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ |@ @@@@9BytesLabels.get_uint16_ne31get_uint16_ne b i$ is !b D's native-endian unsigned 16-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ @ @@@@9BytesLabels.get_uint16_be31get_uint16_be b i$ is !b A's big-endian unsigned 16-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ @ @@@@Ơ9BytesLabels.get_uint16_le31get_uint16_le b i$ is !b D's little-endian unsigned 16-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ @ @@@@͠8BytesLabels.get_int16_ne30get_int16_ne b i$ is !b B's native-endian signed 16-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@@ @@@@Ԡ8BytesLabels.get_int16_be30get_int16_be b i$ is !b ?'s big-endian signed 16-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@+@.@@@@۠8BytesLabels.get_int16_le30get_int16_le b i$ is !b B's little-endian signed 16-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@N@Q@@@@⠕8BytesLabels.get_int32_ne30get_int32_ne b i$ is !b ;'s native-endian 32-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@q@t@@@@蠕8BytesLabels.get_int32_be30get_int32_be b i$ is !b 8's big-endian 32-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@@@@@@8BytesLabels.get_int32_le30get_int32_le b i$ is !b ;'s little-endian 32-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@@@@@@8BytesLabels.get_int64_ne30get_int64_ne b i$ is !b ;'s native-endian 64-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ @@@@@8BytesLabels.get_int64_be30get_int64_be b i$ is !b 8's big-endian 64-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@@ @@@@8BytesLabels.get_int64_le30get_int64_le b i$ is !b ;'s little-endian 64-bit integer starting at byte index !i!.@@@@$4.08@@@@@@@@ @#@@@@ 5BytesLabels.set_uint83/set_uint8 b i v& sets !b 5's unsigned 8-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@"@I#@L@O@@@@4BytesLabels.set_int83.set_int8 b i v& sets !b 3's signed 8-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@+@u,@x(@{$@@@@9BytesLabels.set_uint16_ne33set_uint16_ne b i v& sets !b D's native-endian unsigned 16-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@4@5@1@-@@@@%9BytesLabels.set_uint16_be33set_uint16_be b i v& sets !b A's big-endian unsigned 16-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@=@>@:@6@@@@.9BytesLabels.set_uint16_le33set_uint16_le b i v& sets !b D's little-endian unsigned 16-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@F@G@C@?@@@@78BytesLabels.set_int16_ne32set_int16_ne b i v& sets !b B's native-endian signed 16-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@O@%P@(L@+H@@@@@8BytesLabels.set_int16_be32set_int16_be b i v& sets !b ?'s big-endian signed 16-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@X@QY@TU@WQ@@@@I8BytesLabels.set_int16_le32set_int16_le b i v& sets !b B's little-endian signed 16-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@a@}b@^@Z@@@@R8BytesLabels.set_int32_ne32set_int32_ne b i v& sets !b ;'s native-endian 32-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@j@k@g@c@@@@[8BytesLabels.set_int32_be32set_int32_be b i v& sets !b 8's big-endian 32-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@s@t@p@l@@@@d8BytesLabels.set_int32_le32set_int32_le b i v& sets !b ;'s little-endian 32-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@|@}@y@u@@@@m8BytesLabels.set_int64_ne32set_int64_ne b i v& sets !b ;'s native-endian 64-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@@-@0@3~@@@@v8BytesLabels.set_int64_be32set_int64_be b i v& sets !b 8's big-endian 64-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@@Y@\@_@@@@8BytesLabels.set_int64_le32set_int64_le b i v& sets !b ;'s little-endian 64-bit integer starting at byte index !i$ to !v!.@@@@$4.08@@@@@@@@@@@@@@A1bytes_concurrency %Byte sequences and concurrency safety@@ Care must be taken when concurrently accessing byte sequences from multiple domains: accessing a byte sequence will never crash a program, but unsynchronized accesses might yield surprising (non-sequentially-consistent) results.@% B.byte_atomicity)Atomicity@@ | Every byte sequence operation that accesses more than one byte is not atomic. This includes iteration and scanning.@ 2 For example, consider the following program: !let size = 100_000_000 let b = Bytes.make size ' ' let update b f () = Bytes.iteri (fun i x -> Bytes.set b i (Char.chr (f (Char.code x)))) b let d1 = Domain.spawn (update b (fun x -> x + 1)) let d2 = Domain.spawn (update b (fun x -> 2 * x + 1)) let () = Domain.join d1; Domain.join d2 8 the bytes sequence !b 0 may contain a non-deterministic mixture of #'!'", #'A'", #'B'&, and #'C'( values.@ : After executing this code, each byte of the sequence !b+ is either #'!'&, #'A'", #'B'%, or #'C' k. If atomicity is required, then the user must implement their own synchronization (for example, using 'Mutex.t@@").@% B/bytes_data_race*Data races@@ If two domains only access disjoint parts of a byte sequence, then the observed behaviour is the equivalent to some sequential interleaving of the operations from the two domains.@ % A data race is said to occur when two domains access the same byte without synchronization and at least one of the accesses is a write. In the absence of data races, the observed behaviour is equivalent to some sequential interleaving of the operations from different domains.@ Whenever possible, data races should be avoided by using synchronization to mediate the accesses to the elements of the sequence.@ H Indeed, in the presence of data races, programs will not crash but the observed behaviour may not be equivalent to any sequential interleaving of operations from different domains. Nevertheless, even in the presence of data races, a read operation will return the value of some prior write to that location.@% B2bytes_mixed_access4Mixed-size accesses @@  Another subtle point is that if a data race involves mixed-size writes and reads to the same location, the order in which those writes and reads are observed by domains is not specified. For instance, the following code write sequentially a 32-bit integer and a $char3 to the same index j let b = Bytes.make 10 '\000' let d1 = Domain.spawn (fun () -> Bytes.set_int32_ne b 0 100; b.[0] <- 'd' ) @ E In this situation, a domain that observes the write of 'd' to b.!0 < is not guaranteed to also observe the write to indices !1", !2%, or !3!.@@@[@@A%Uchar#Seq@@@@@