glendam/protocol_support

Supports generated Chrome DevTools Protocol encoders and decoders.

Types

Represents an enabled or disabled protocol setting.

pub type BooleanSetting {
  Enabled
  Disabled
}

Constructors

  • Enabled

    The protocol setting is enabled.

  • Disabled

    The protocol setting is disabled.

Values

pub fn add_optional(
  to properties: List(#(String, json.Json)),
  value value: option.Option(value),
  encoded_by encode: fn(value) -> #(String, json.Json),
) -> List(#(String, json.Json))

Adds an encoded property only when its source value is present.

pub fn boolean_setting_decoder() -> decode.Decoder(BooleanSetting)

Decodes a JSON boolean into a protocol setting.

pub fn boolean_setting_to_bool(
  setting setting: BooleanSetting,
) -> Bool

Converts a protocol setting into a Gleam boolean at the JSON boundary.

pub fn decode_number() -> decode.Decoder(Float)

Decodes a CDP number, accepting both JSON integers and floats.

pub fn encode_boolean_setting(
  setting setting: BooleanSetting,
) -> json.Json

Converts a protocol setting to a JSON boolean.

pub fn encode_unrepresentable_dynamic(
  value value: value,
) -> json.Json

Encodes an unsupported dynamic CDP value as JSON null.

CDP schema fields declared as any cannot be represented bidirectionally by generated Gleam types. The generated encoder therefore uses the protocol’s null sentinel instead of pretending the value was encoded.

Search Document