kata/format
Types
Unified error for format-aware decoding.
pub type DecodeError {
ParseError(message: String)
SchemaError(errors: List(error.Error))
}
Constructors
-
ParseError(message: String)The raw input could not be parsed into a Value.
-
SchemaError(errors: List(error.Error))The Value did not match the schema.
A pluggable wire format that converts between raw representation and Value.
pub type Format(raw) {
Format(
name: String,
parse: fn(raw) -> Result(value.Value, String),
serialize: fn(value.Value) -> Result(raw, String),
mode: ParseMode,
)
}
Constructors
-
Format( name: String, parse: fn(raw) -> Result(value.Value, String), serialize: fn(value.Value) -> Result(raw, String), mode: ParseMode, )
Values
pub fn decode(
s: schema.Schema(a),
format: Format(raw),
input: raw,
) -> Result(a, DecodeError)
Decode raw input through a format and schema in one step.
pub fn encode(
s: schema.Schema(a),
format: Format(raw),
value: a,
) -> Result(raw, String)
Encode a typed value to raw output through a schema and format.