Lightning.Runtime.LogAgent.StringBuffer (Lightning v2.14.5-pre1)

View Source

Internal datastructure to hold and process new bytes for a list of characters.

By checking the if the buffer is a complete grapheme, emitting the buffer once valid and returning nil otherwise.

In the case of emojis and other language character sets, a character (in UTF-8) can be between 1-4 bytes - when streaming logs for example it's quite easy to receive less than the whole character which can result in crashes or corrupt text.

Summary

Types

t()

@type t() :: {buffer :: buffer(), chunk_state :: chunk_state()}

Functions

buffer(arg)

@spec buffer(state :: t()) :: [binary()]

new()

@spec new() :: t()

process_chunk(data, arg)

@spec process_chunk(data :: any(), state :: t()) :: {binary() | nil, t()}

reduce_chunk(data, arg)

@spec reduce_chunk(data :: any(), chunk_state :: chunk_state()) ::
  {binary() | nil, chunk_state()}