Zenohex.Config (Zenohex v0.7.1)

View Source

Utility functions for working with Zenoh session configurations.

This module provides helpers to obtain default configuration, parse JSON5 strings, and manipulate nested config structures using Elixir functions.

Summary

Functions

Returns the default Zenoh configuration as a JSON5 binary.

Updates a key in a nested JSON binary.

Types

t()

@type t() :: String.t()

Functions

default()

@spec default() :: t()

Returns the default Zenoh configuration as a JSON5 binary.

The returned configuration is valid input for Zenohex.Session.open/1.

Examples

Print the config in a readable form to check its contents.

iex> config = Zenohex.Config.default()
iex> config |> :json.decode() |> :json.format() |> IO.puts()

update_in(config, keys, fun)

@spec update_in(t(), [term(), ...], (term() -> term())) :: t()

Updates a key in a nested JSON binary.

This function decodes the JSON, applies the given function to the value at the specified path, and re-encodes the result into a binary.

Parameters

  • config: A JSON config binary.
  • keys: A list representing the nested path to update.
  • fun: A function to apply to the value at the specified path.

Examples

iex> config = Zenohex.Config.default()
iex> Zenohex.Config.update_in(config, ["scouting", "delay"], fn _ -> 100 end)