moduleCodec=Protobuf_codecmoduleD=Protobuf_codec.DecodermoduleState=structtypet=D.tletof_bytes=D.of_bytesendtypetag=inttype'at=(State.t->'a)(* Applicative boilerplate *)moduleApplicative=structletappfv=fund->letf'=fdinletv'=vdinf'v'let(<*>)=appletconstv=fun_->vletfmapfv=constf<*>vlet(<$>)=fmapendmoduleEncoding=structtypetyp=|Varint|Zigzag|Bits32|Bits64|Bytestype'at=(typ*(D.t->'a))letvarint=(Varint,D.varint)letzigzag=(Zigzag,D.zigzag)letbits32=(Bits32,D.bits32)letbits64=(Bits64,D.bits64)letbytes=(Bytes,D.bytes)letdecode(_,decoder)=decoderletequal_pk(typ,_)pk=match(typ,pk)with|(Varint,Codec.Varint)->true|(Zigzag,Codec.Varint)->true|(Bits32,Codec.Bits32)->true|(Bits64,Codec.Bits64)->true|(Bytes,Codec.Bytes)->true|_->falseendletreadtagtypd=matchD.keydwith|Some(tag',typ')whentag=tag'&&Encoding.equal_pktyptyp'->Encoding.decodetypd|_->failwith"bad type or tag"letrunsdecoder=decoders(* Conversions *)letenumtagconvd=conv(D.int_of_int64"enum"(readtagEncoding.varintd))letbooltagd=Int64.compare(readtagEncoding.varintd)Int64.zero<>0letint32tagd=D.int32_of_int64"int32"(readtagEncoding.varintd)letsint32tagd=D.int32_of_int64"sint32"(readtagEncoding.zigzagd)letint64tagd=readtagEncoding.varintdletsint64tagd=readtagEncoding.zigzagdletfloattagd=Int32.float_of_bits(readtagEncoding.bits32d)letdoubletagd=Int64.float_of_bits(readtagEncoding.bits64d)letbytestagd=readtagEncoding.bytesdletstring=bytesletembd_msgtagconvd=letb=readtagEncoding.bytesdinletd'=State.of_bytesbinrund'conv
type'atmoduleState:sigtypetvalof_bytes:bytes->tendmoduleApplicative:sigvalapp:('a->'b)t->'at->'btval(<*>):('a->'b)t->'at->'btvalconst:'a->'atvalfmap:('a->'b)->'at->'btval(<$>):('a->'b)->'at->'btendtypetag=intvalrun:State.t->'at->'avalenum:tag->(int->'a)->'atvalbool:tag->booltvalint32:tag->Int32.ttvalsint32:tag->Int32.ttvalint64:tag->Int64.ttvalsint64:tag->Int64.ttvalfloat:tag->floattvaldouble:tag->floattvalstring:tag->bytestvalbytes:tag->bytestvalembd_msg:tag->'at->'at(* val enum_opt : tag -> (int -> ('a, error) Result.t) -> 'a option t *)(* val bool_opt : tag -> bool option t *)(* val int32_opt : tag -> Int32.t option t *)(* val sint32_opt : tag -> Int32.t option t *)(* val int64_opt : tag -> Int64.t option t *)(* val sint64_opt : tag -> Int64.t option t *)(* val float_opt : tag -> Float.t option t *)(* val double_opt : tag -> Float.t option t *)(* val string_opt : tag -> String.t option t *)(* val bytes_opt : tag -> String.t option t *)(* val embd_msg_opt : tag -> 'a t -> 'a option t *)(* val enum_rep : tag -> (int -> ('a, error) Result.t) -> 'a list t *)(* val bool_rep : tag -> bool list t *)(* val int32_rep : tag -> Int32.t list t *)(* val sint32_rep : tag -> Int32.t list t *)(* val int64_rep : tag -> Int64.t list t *)(* val sint64_rep : tag -> Int64.t list t *)(* val float_rep : tag -> Float.t list t *)(* val double_rep : tag -> Float.t list t *)(* val string_rep : tag -> String.t list t *)(* val bytes_rep : tag -> String.t list t *)(* val embd_msg_rep : tag -> 'a t -> 'a list t *)(* val enum_pkd : tag -> (int -> ('a, error) Result.t) -> 'a list t *)(* val bool_pkd : tag -> bool list t *)(* val int32_pkd : tag -> Int32.t list t *)(* val sint32_pkd : tag -> Int32.t list t *)(* val int64_pkd : tag -> Int64.t list t *)(* val sint64_pkd : tag -> Int64.t list t *)(* val float_pkd : tag -> Float.t list t *)(* val double_pkd : tag -> Float.t list t *)
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.