package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65

doc/octez-libs.stdlib/Tezos_stdlib/Circular_buffer/index.html

Module Tezos_stdlib.Circular_bufferSource

This module implements a bufferisation abstraction to store temporary raw data chunks (as bytes) when chunks are read sequentially. The function write allows to store chunks in the buffer and the function read to read them from the buffer.

The global contract is that if we write consecutively d1;d2 onto the buffer, then we have to fully read d1 and d2, in that order.

This contract is not enforced by the library, it is the user responsibility to respect it.

If the circular buffer is full, a new temporary buffer is allocated to store the chunk of data to be written.

Sourcetype t

Type of circular buffers

Sourcetype data

An abstraction over a chunk of data written in the buffer.

Sourceval create : ?maxlength:int -> ?fresh_buf_size:int -> unit -> t

create ?maxlength ?fresh_buf_size () creates a buffer of size maxlength (by default 32 kb). If the buffer is full, a buffer of size fresh_buf_size is allocated (by default 2 kb).

Sourceval write : maxlen:int -> fill_using:(Bytes.t -> int -> int -> (int, 'error) result Lwt.t) -> t -> (data, 'error) result Lwt.t

write ~maxlen ~fill_using buffer calls fill_using buf offset maxlen where buf is a buffer that has room for maxlen data starting from offset.

Assumes that fill_using returns the exact amount of written bytes.

Behaviour is unspecified if fill_using writes more than maxlen data or lies on the number of written bytes.

It returns a data descriptor for the supposedly written chunk.

Sourceval read : data -> ?len:int -> t -> into:Bytes.t -> offset:int -> data option

read data ~len ~into:buf buffer ~offset copies len data from the data chunk into buf. If len is not provided, it copies all the data. If len is less than the amount of data available, it returns a new handler of the remainder.

  • Assumes that data has been produced by a write attempt in buffer.
  • Assumes that len is less than length data.
Sourceval length : data -> int

length data returns the amount of available bytes in data

OCaml

Innovation. Community. Security.