sparkling/format/registry

Types

Format handler for a specific ClickHouse format

pub type FormatHandler {
  FormatHandler(
    name: String,
    encode: fn(List(dict.Dict(String, json.Json))) -> Result(
      String,
      String,
    ),
    decode: fn(String) -> Result(
      List(dict.Dict(String, json.Json)),
      String,
    ),
  )
}

Constructors

  • FormatHandler(
      name: String,
      encode: fn(List(dict.Dict(String, json.Json))) -> Result(
        String,
        String,
      ),
      decode: fn(String) -> Result(
        List(dict.Dict(String, json.Json)),
        String,
      ),
    )

Global registry of format handlers

pub opaque type FormatRegistry

Values

pub fn decode(
  registry: FormatRegistry,
  format_name: String,
  data: String,
) -> Result(List(dict.Dict(String, json.Json)), String)

Decode data using the specified format

pub fn default_registry() -> FormatRegistry

Create default registry with all available format handlers Includes: JSONEachRow, TabSeparated, CSV

pub fn encode(
  registry: FormatRegistry,
  format_name: String,
  data: List(dict.Dict(String, json.Json)),
) -> Result(String, String)

Encode data using the specified format

pub fn get_handler(
  registry: FormatRegistry,
  format_name: String,
) -> option.Option(FormatHandler)

Get a format handler by name

pub fn list_formats(registry: FormatRegistry) -> List(String)

List all registered format names

pub fn new() -> FormatRegistry

Create a new empty format registry

pub fn register(
  registry: FormatRegistry,
  handler: FormatHandler,
) -> FormatRegistry

Register a format handler

Search Document