Module Proto.Twrite

A Twrite request provides data to be recorded in an open file at a given offset.

type t
val size : t -> int

The size of this message in bytes. It is identical to the length of the underlying I/O vector but is also encoded in the first 4 bytes of the message.

val code : int

The op code for this message.

val tag : t -> Tag.t

An identifier for this transaction. All in-flight requests on a given connection must have unique tags.

val of_iovec : Iovec.t -> t

of_iovec verifies a message from an I/O vector. No copying is done, and of_iovec only performs bounds checks. Modifying the underlying I/O vector will change the results when accessing message fields.

val fid : t -> Fid.t

The file to write to. Must be prepared with Topen or Tcreate.

val offset : t -> int

The offset at which to start writing data. If the file is open in append-only mode, this field is ignored.

val offset64 : t -> int64

The offset, as a newly allocated int64.

val data : t -> Iovec.t

The data to be written to the file.

val alloc : Iovec.t -> tag:Tag.t -> fid:Fid.t -> offset:int -> max:int -> t

alloc iov ~max writes and returns a Twrite message to iov with a payload of up to max bytes. It does not populate or clear the payload. The caller must fill data msg and use commit to update the message's count header. Care must be taken to avoid sending the uninitialized message.

val commit : t -> count:int -> int

commit m ~count updates the message's count field and returns the updated size of the message.