Module dslib:raw_buffer

Secure wrapper for raw cdata buffers.

Note: This is very experimental.

See RawBuffer.

Functions

new_RawBuffer () Creates a new RawBuffer.

Class RawBuffer

RawBuffer:size () Returns the size of a buffer.
RawBuffer:capacity () Returns the capacity of a buffer.
RawBuffer:reserve (new_capacity) Increases the capacity of the buffer.
RawBuffer:resize (new_size) In- or decreases the size of the buffer.
RawBuffer:read_u8 (offset) Reads an unsigned 8-bit integer at a given byte-offset.
RawBuffer:read_u16 (offset) Reads an unsigned 16-bit integer at a given byte-offset.
RawBuffer:read_u32 (offset) Reads an unsigned 32-bit integer at a given byte-offset.
RawBuffer:read_u64 (offset) Reads an unsigned 64-bit integer at a given byte-offset.
RawBuffer:read_i8 (offset) Reads a signed 8-bit integer at a given byte-offset.
RawBuffer:read_i16 (offset) Reads a signed 16-bit integer at a given byte-offset.
RawBuffer:read_i32 (offset) Reads a signed 32-bit integer at a given byte-offset.
RawBuffer:read_i64 (offset) Reads a signed 64-bit integer at a given byte-offset.
RawBuffer:read_f32 (offset) Reads a 32-bit floating-point number (a float) at a given byte-offset.
RawBuffer:read_f64 (offset) Reads a 64-bit floating-point number (a double) at a given byte-offset.
RawBuffer:read_string (offset, len) Reads a string of a given length at a given byte-offset.
RawBuffer:write_u8 (offset, value) Writes an unsigned 8-bit integer at a given byte-offset.
RawBuffer:write_u16 (offset, value) Writes an unsigned 16-bit integer at a given byte-offset.
RawBuffer:write_u32 (offset, value) Writes an unsigned 32-bit integer at a given byte-offset.
RawBuffer:write_u64 (offset, value) Writes an unsigned 64-bit integer at a given byte-offset.
RawBuffer:write_i8 (offset, value) Writes a signed 8-bit integer at a given byte-offset.
RawBuffer:write_i16 (offset, value) Writes a signed 16-bit integer at a given byte-offset.
RawBuffer:write_i32 (offset, value) Writes a signed 32-bit integer at a given byte-offset.
RawBuffer:write_i64 (offset, value) Writes a signed 64-bit integer at a given byte-offset.
RawBuffer:write_f32 (offset, value) Writes a 32-bit floating-point number (a float) at a given byte-offset.
RawBuffer:write_f64 (offset, value) Writes a 64-bit floating-point number (a double) at a given byte-offset.
RawBuffer:copy_from () TODO
RawBuffer:append_u8 (value) Appends an unsigned 8-bit integer to the end of the buffer.
RawBuffer:append_u16 (value) Appends an unsigned 16-bit integer to the end of the buffer.
RawBuffer:append_u32 (value) Appends an unsigned 32-bit integer to the end of the buffer.
RawBuffer:append_u64 (value) Appends an unsigned 64-bit integer to the end of the buffer.
RawBuffer:append_i8 (value) Appends a signed 8-bit integer to the end of the buffer.
RawBuffer:append_i16 (value) Appends a signed 16-bit integer to the end of the buffer.
RawBuffer:append_i32 (value) Appends a signed 32-bit integer to the end of the buffer.
RawBuffer:append_i64 (value) Appends a signed 64-bit integer to the end of the buffer.
RawBuffer:append_f32 (value) Appends a 32-bit floating-point number (a float) to the end of the buffer.
RawBuffer:append_f64 (value) Appends a 64-bit floating-point number (a double) to the end of the buffer.


Functions

new_RawBuffer () line 136
Creates a new RawBuffer.

Returns:

    RawBuffer The new buffer.

Class RawBuffer

A byte-addressable secure wrapper for a cdata buffer.

Maximum size is currently about 0x1p60 bytes.

Integer types can be numbers or 64 bit LuaJIT cdata integers (ie. 1ULL).

Note: The API is very unstable.

RawBuffer:size () line 242
Returns the size of a buffer. You can not read or write outside of this size.

Returns:

    int The size.
RawBuffer:capacity () line 250
Returns the capacity of a buffer.

Returns:

    int The capacity.
RawBuffer:reserve (new_capacity) line 260
Increases the capacity of the buffer. Size is not influenced. Capacity is never decreased.

Parameters:

  • new_capacity int The requested minimal new capacity.
RawBuffer:resize (new_size) line 295
In- or decreases the size of the buffer. If size is increased, new data is filled with 0s.

Parameters:

  • new_size int The new size.
RawBuffer:read_u8 (offset) line 340
Reads an unsigned 8-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The u8 value at the given offset.
RawBuffer:read_u16 (offset) line 345
Reads an unsigned 16-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The u16 value at the given offset.
RawBuffer:read_u32 (offset) line 350
Reads an unsigned 32-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The u32 value at the given offset.
RawBuffer:read_u64 (offset) line 355
Reads an unsigned 64-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The u64 value at the given offset. It is a uint64_t cdata value.
RawBuffer:read_i8 (offset) line 360
Reads a signed 8-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The i8 value at the given offset.
RawBuffer:read_i16 (offset) line 365
Reads a signed 16-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The i16 value at the given offset.
RawBuffer:read_i32 (offset) line 370
Reads a signed 32-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    int The i32 value at the given offset.
RawBuffer:read_i64 (offset) line 375
Reads a signed 64-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer

Returns:

    int The i64 value at the given offset. It is an int64_t cdata value.
RawBuffer:read_f32 (offset) line 379
Reads a 32-bit floating-point number (a float) at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    number The f32 value at the given offset.
RawBuffer:read_f64 (offset) line 385
Reads a 64-bit floating-point number (a double) at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.

Returns:

    number The f64 value at the given offset.
RawBuffer:read_string (offset, len) line 392
Reads a string of a given length at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer.
  • len int Length of the string. Must not exceed buffer size.

Returns:

    string A copy of the data as string.
RawBuffer:write_u8 (offset, value) line 441
Writes an unsigned 8-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The u8 value to write.
RawBuffer:write_u16 (offset, value) line 446
Writes an unsigned 16-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The u16 value to write.
RawBuffer:write_u32 (offset, value) line 451
Writes an unsigned 32-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The u32 value to write.
RawBuffer:write_u64 (offset, value) line 456
Writes an unsigned 64-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The u64 value to write. Can be a uint64_t cdata value.
RawBuffer:write_i8 (offset, value) line 461
Writes a signed 8-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The i8 value to write.
RawBuffer:write_i16 (offset, value) line 466
Writes a signed 16-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The i16 value to write.
RawBuffer:write_i32 (offset, value) line 471
Writes a signed 32-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The i32 value to write.
RawBuffer:write_i64 (offset, value) line 476
Writes a signed 64-bit integer at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value int The i64 value to write. Can be an int64_t cdata value.
RawBuffer:write_f32 (offset, value) line 480
Writes a 32-bit floating-point number (a float) at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value number The f32 value to write.
RawBuffer:write_f64 (offset, value) line 486
Writes a 64-bit floating-point number (a double) at a given byte-offset.

Parameters:

  • offset int Byte-offset in the buffer
  • value number The f64 value to write.
RawBuffer:copy_from () line 490
TODO
RawBuffer:append_u8 (value) line 552
Appends an unsigned 8-bit integer to the end of the buffer.

Parameters:

  • value int The u8 value to write.
RawBuffer:append_u16 (value) line 556
Appends an unsigned 16-bit integer to the end of the buffer.

Parameters:

  • value int The u16 value to write.
RawBuffer:append_u32 (value) line 560
Appends an unsigned 32-bit integer to the end of the buffer.

Parameters:

  • value int The u32 value to write.
RawBuffer:append_u64 (value) line 564
Appends an unsigned 64-bit integer to the end of the buffer.

Parameters:

  • value int The u64 value to write. Can be a uint64_t cdata value.
RawBuffer:append_i8 (value) line 568
Appends a signed 8-bit integer to the end of the buffer.

Parameters:

  • value int The i8 value to write.
RawBuffer:append_i16 (value) line 572
Appends a signed 16-bit integer to the end of the buffer.

Parameters:

  • value int The i16 value to write.
RawBuffer:append_i32 (value) line 576
Appends a signed 32-bit integer to the end of the buffer.

Parameters:

  • value int The i32 value to write.
RawBuffer:append_i64 (value) line 580
Appends a signed 64-bit integer to the end of the buffer.

Parameters:

  • value int The i64 value to write. Can be an int64_t cdata value.
RawBuffer:append_f32 (value) line 583
Appends a 32-bit floating-point number (a float) to the end of the buffer.

Parameters:

  • value number The f32 value to write.
RawBuffer:append_f64 (value) line 588
Appends a 64-bit floating-point number (a double) to the end of the buffer.

Parameters:

  • value number The f64 value to write.
generated by LDoc 1.4.6 Last updated 2023-04-02 20:41:54