std.yaml
Types
struct YamlError
Functions
[src]
pub fn parse<T>(input: string | Bytes | Read): T throws YamlError {
switch (let input = input.(type)) {
case string:
return try _yaml.parse::<T>(_create_native_read(Cursor.new(input)));
case Bytes:
return try _yaml.parse::<T>(_create_native_read(Cursor.new(input)));
case Read:
return try _yaml.parse::<T>(_create_native_read(input));
}
}
Parse a YAML into specific type.
[src]
pub fn parse<T>(input: string | Bytes | Read): T throws YamlError {
switch (let input = input.(type)) {
case string:
return try _yaml.parse::<T>(_create_native_read(Cursor.new(input)));
case Bytes:
return try _yaml.parse::<T>(_create_native_read(Cursor.new(input)));
case Read:
return try _yaml.parse::<T>(_create_native_read(input));
}
}
Parse a YAML into specific type.
Parse a YAML into specific type.
nv
use std.yaml;
struct User {
name: string,
id: int,
}
let user = try! yaml.parse::<User>(`
name: Sunli
id: 123456
`);
assert_eq user.name, "Sunli";
assert_eq user.id, 123456;
[src]
pub fn to_string<T>(value: T): string throws YamlError {
let buf = Bytes.new();
try _yaml.to_writer(_create_native_write(buf), value);
return buf.to_string();
}
Serialize the given value as YAML into a string.
[src]
pub fn to_string<T>(value: T): string throws YamlError {
let buf = Bytes.new();
try _yaml.to_writer(_create_native_write(buf), value);
return buf.to_string();
}
Serialize the given value as YAML into a string.
Serialize the given value as YAML into a string.
nv
use std.yaml;
struct User {
name: string,
id: int,
profile: Profile
}
struct Profile {
city: string
}
let user = User {
name: "Sunli",
id: 123456,
profile: Profile {
city: "Wuhan"
}
};
let result = try! yaml.to_string(user);
assert_eq result, "name: Sunli\nid: 123456\nprofile:\n city: Wuhan\n";
[src]
pub fn to_writer<T>(writer: Write, value: T) throws YamlError {
try _yaml.to_writer(_create_native_write(writer), value);
}
Serialize the given value as YAML to std.io.Write
.
[src]
pub fn to_writer<T>(writer: Write, value: T) throws YamlError {
try _yaml.to_writer(_create_native_write(writer), value);
}
Serialize the given value as YAML to std.io.Write
.
Serialize the given value as YAML to std.io.Write
.
nv
use std.io.Bytes;
use std.yaml;
struct User {
name: string,
}
let buf = Bytes.new();
let user = User { name: "Jason Lee" };
try! yaml.to_writer(buf, user);
assert_eq buf.to_string(), `name: Jason Lee\n`;