Module Proto.Rread

An Rread returns the requested data from a file. It is not an error for the data returned to be less than the data requested.

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 data : t -> Iovec.t

The requested data. The data is not copied, and will be lost if the underlying storage is modified. It is not considered an error for this to be less than the number of bytes requested, but it shall not be greater.

val alloc : Iovec.ring -> max:int -> t

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

val commit : t -> tag:Tag.t -> count:int -> int

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