Module bin.buf

This module implements write buffer.

You should use it if you want to collect some data for write.

Example of usage moonlibs/connection-scribe

Class buf

buf:pv() Returns raw pointer Doesn't grant ownership.
buf:export() Exports data from buffer for external use.
buf.new(size) Creates new buffer


Class buf

Implements write buffer. Has following structure inside

struct bin_buf {
      char  *buf;
      size_t cur;
      size_t len;
};
buf:pv()
Returns raw pointer Doesn't grant ownership.

You can't continue to use pointer after buffer modification or after free of original object

Mind GC!

Returns:

  1. char * start of the buffer
  2. size of written bytes
buf:export()
Exports data from buffer for external use.

Grants ownership of struct to the returned value (including gc) use object after export is prohibited

Returns:

  1. char * start of the buffer
  2. size of written data inside buffer
  3. capacity - allocated bytes of the buffer
buf.new(size)
Creates new buffer

Parameters:

  • size initial capacity of the buffer aligned to 64bytes

Returns:

    buf buffer new empty buffer
generated by LDoc 1.4.6 Last updated 2022-05-19 12:17:27