Module type Smart.ENCODER

module Hash : sig ... end
module Reference : Reference.S with module Hash := Hash
module Common : COMMON with type hash := Hash.t and type reference := Reference.t
type encoder

The type encoder.

val set_pos : encoder -> int -> unit

set_pos encoder pos is unsafe and change the internal position of the encoder. Don't use it.

val free : encoder -> Cstruct.t

free encoder returns the free internal buffer of the encoder. Don't use it.

type 'a state =
| Write of {
buffer : Cstruct.t;
off : int;
len : int;
continue : int -> 'a state;
}

Means that we want to flush the internal buffer of the encoder. We provide and Cstruct.t with an offset and a length. The client is able to Cstruct.blit this buffer to e output in this range. Then, he can call continue with how many byte(s) he wrote.

| Ok of 'a

The end value of the encoding.

type action = [
| `GitProtoRequest of Common.git_proto_request
| `UploadRequest of Common.upload_request
| `HttpUploadRequest of [ `Done | `Flush ] * Common.http_upload_request
| `Advertised_refs of Common.advertised_refs
| `Shallow_update of Common.shallow_update
| `Negociation of Common.acks
| `Negociation_result of Common.negociation_result
| `Report_status of [ `No_multiplexe | `Side_band | `Side_band_64k ] * Common.report_status
| `UpdateRequest of Common.update_request
| `HttpUpdateRequest of Common.update_request
| `Has of Hash.Set.t
| `Done
| `Flush
| `Shallow of Hash.t list
| `PACK of int
]

The type action to describe what is expected to encode/send.

val encode : encoder -> action -> unit state

encode encoder action encodes to an output represented by encoder in the way of the action and returns an unit value.

val encoder : unit -> encoder

encoder () makes a new decoder.

val to_string : action -> string