Zenohex.Config (Zenohex v0.7.1)
View SourceUtility 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
@type t() :: String.t()
Functions
@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()
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)