Module std::encoding::yaml

YAML parsing.

Parse YAML documents into values, inspect types, extract fields, and serialize back to YAML text.

Examples

import std::encoding::yaml;

fn main() {
    let doc = yaml.parse("name: Hew\nversion: 1");
    let name = doc.get_field("name");
    println(name.get_string());  // "Hew"
    name.free();
    doc.free();
}

Contents

Functions

Function parse

pub fn parse(s: String) -> Value

Parse a YAML string into a Value.

Panics if the input is not valid YAML.

Examples

let config = yaml.parse("host: localhost\nport: 8080");

Types

Struct Value

An opaque YAML value.

Represents any YAML type: null, bool, integer, float, String, sequence, or mapping. Created by yaml.parse(s) or by navigating into a parsed value. Must be freed with free() when no longer needed.

Traits

Trait ValueMethods

Methods available on a YAML Value.

Methods

fn stringify(self: Value) -> String fn type_of(self: Value) -> i32 fn get_bool(self: Value) -> i32 fn get_int(self: Value) -> i64 fn get_float(self: Value) -> f64 fn get_string(self: Value) -> String fn get_field(self: Value, key: String) -> Value fn array_len(self: Value) -> i32 fn array_get(self: Value, index: i32) -> Value fn free(self: Value)