123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191openCommonmoduleT=structtype'at='a[@@derivingcompare,sexp_of]letbin_shape_tt=Shape.(basetype(Uuid.of_string"85a2557e-490a-11e6-98ac-4b8953d525fe")[t]);;letbin_size_tbin_size_aa=Utils.size_header_length+bin_size_aaletbin_write_tbin_write_abuf~posa=letstart_a=pos+Utils.size_header_lengthinletend_a=bin_write_abuf~pos:start_aainletsize=end_a-start_ainletwritten=Utils.bin_write_size_headerbuf~possizeinassert(written=start_a);end_a;;letbin_read_tbin_read_abuf~pos_ref=letexpected_size=Utils.bin_read_size_headerbuf~pos_refinletstart_a=!pos_refinleta=bin_read_abuf~pos_refinletend_a=!pos_refinifend_a-start_a<>expected_sizethenfailwith(Printf.sprintf"Bin_prot.Blob.bin_read_t: size (%d) <> expected (%d)"(end_a-start_a)expected_size);a;;let__bin_read_t____~pos_ref=raise_variant_wrong_type"Bin_prot.Blob.t"!pos_ref;;endtype'aid='aincludeTincludeUtils.Make_binable1_without_uuid[@alert"-legacy"](structmoduleBinable=Ttype'at='aT.tletof_binablet=tletto_binablet=tend)moduleOpaque=struct(* [Bigstring] and [String] share [bin_shape_t] because they have exactly the same
serialization format and they denote the same values.
In fact almost certainly [Blob.t] itself should have the same bin_shape_t as well. *)letbin_shape_t=Shape.(basetype(Uuid.of_string"85a1f76e-490a-11e6-86a9-5bef585f2602")[]);;moduleBigstring=struct(* [buf] is the bin-io data excluding the size header. When (de-)serialized, the size
header is included. *)moduleT=structtypet=bufletbin_shape_t=bin_shape_tletbin_size_tt=Utils.size_header_length+buf_lentletbin_write_tbuf~post=letsize=buf_lentinletpos=Utils.bin_write_size_headerbuf~possizeinblit_buf~src:t~src_pos:0~dst:buf~dst_pos:possize;pos+size;;letbin_read_tbuf~pos_ref=letsize=Utils.bin_read_size_headerbuf~pos_refinlett=create_bufsizeinblit_buf~src:buf~src_pos:!pos_ref~dst:t~dst_pos:0size;pos_ref:=!pos_ref+size;t;;let__bin_read_t___~pos_ref=raise_variant_wrong_type"Bin_prot.Blob.Opaque.t"!pos_ref;;endincludeTincludeUtils.Of_minimal(T)letto_opaqueblobbin_writer=Utils.bin_dumpbin_writerblobletof_opaque_exn(t:t)bin_reader=bin_reader.Type_class.readt~pos_ref:(ref0)(* Bigstrings are a primitive type that polymorphic compare handles well. *)letcompare=(Stdlib.compare:buf->buf->int)letsexp_of_tt=Ppx_sexp_conv_lib.Sexp.Atom(of_opaque_exntType_class.bin_reader_string);;endmoduleString=structmoduleT=structtypet=stringletbin_shape_t=bin_shape_tletbin_size_tt=Utils.size_header_length+String.lengthtletbin_write_tbuf~post=letsize=String.lengthtinletpos=Utils.bin_write_size_headerbuf~possizeinCommon.blit_string_buft~src_pos:0buf~dst_pos:pos~len:size;pos+size;;letstring_of_bigstringbuf~pos~len=letstr=Bytes.createleninblit_buf_bytes~src_pos:posbuf~dst_pos:0str~len;Bytes.unsafe_to_stringstr;;letbin_read_tbuf~pos_ref=letlen=Utils.bin_read_size_headerbuf~pos_refinlett=string_of_bigstringbuf~pos:!pos_ref~leninpos_ref:=!pos_ref+len;t;;let__bin_read_t___~pos_ref=raise_variant_wrong_type"Bin_prot.Blob.Opaque.t"!pos_ref;;endincludeTincludeUtils.Of_minimal(T)letlengtht=String.lengthtletto_opaque~bufvbin_writer_v:t=letpos=0inletlen=bin_writer_v.Type_class.writebuf~posvinstring_of_bigstringbuf~pos~len;;letof_opaque_exn~buf(t:t)bin_reader_v=letlen=String.lengthtinCommon.blit_string_buftbuf~len;letpos_ref=ref0inletres=bin_reader_v.Type_class.readbuf~pos_refinif!pos_ref<>lenthen(leterror=Printf.sprintf"Opaque blob has %d bytes but [of_opaque_exn] read %d"len!pos_refinfailwitherror)elseres;;(* Strings are a primitive type that polymorphic compare handles well. *)letcompare=(Stdlib.compare:string->string->int)letsexp_of_t=Ppx_sexp_conv_lib.Conv.sexp_of_stringendendmoduleIgnored=struct(* The representation of an ignored value is just the size of the value it was created
from (i.e., the number of bytes that were ignored from the buffer we were reading
-- we exclude the 8 byte size header from which the size was read). *)typet=intletbin_size_tsize=Utils.size_header_length+sizeletbin_read_tbuf~pos_ref=letsize=Utils.bin_read_size_headerbuf~pos_refinpos_ref:=!pos_ref+size;size;;let__bin_read_t___~pos_ref=raise_variant_wrong_type"Bin_prot.Blob.Ignored.t"!pos_ref;;letbin_reader_t={Type_class.read=bin_read_t;vtag_read=__bin_read_t__}end