type alias XmlParam

A Baichuan parameter: a named top-level element of <body>.

Exported codecs are annotated with their value type, which keeps the public API explicit and makes the compiler check the field codecs against it:

export type RtspPort = { rtspPort: number; enable: number };
export const rtspPort: XmlParam<"RtspPort", RtspPort> = xmlParam(
  "RtspPort",
  { rtspPort: int(), enable: int() },
);

Type Parameters

N extends string

The element name, such as "RtspPort".

The decoded value.

Properties

The element name.

The field codecs, in the order they are written.

encode: (value: T) => string

Writes the element, with version="1.1".

decode: (element: XmlElement) => T

Reads the element's fields.

Usage

import { type XmlParam } from "protocol/xml.ts";