Crate kiwi_schema [] [src]

This is a Rust library with some helper routines for parsing files in the Kiwi serialization format. See https://github.com/evanw/kiwi for documentation about the format.

use kiwi_schema::*;

let schema = Schema::new(vec![
  Def::new("Point", DefKind::Struct, vec![
    Field {name: "x".to_owned(), type_id: TYPE_FLOAT, is_array: false, value: 0},
    Field {name: "y".to_owned(), type_id: TYPE_FLOAT, is_array: false, value: 0},
  ]),
]);

let value = Value::decode(&schema, 0, &[126, 0, 0, 0, 126, 1, 0, 0]).unwrap();
assert_eq!(format!("{:?}", value), "Point {x: 0.5, y: -0.5}");
assert_eq!(value.encode(&schema), [126, 0, 0, 0, 126, 1, 0, 0]);

Structs

ByteBuffer

A Kiwi byte buffer meant for reading.

ByteBufferMut

A Kiwi byte buffer meant for writing.

Def

Represents a single definition in a Schema. Kiwi enums, structs, and messages are all represented using this object.

Field

Represents a single field in a Def.

Schema

Holds the contents of a Kiwi schema.

Enums

DefKind
Value

This type holds dynamic Kiwi data.

Constants

DEF_ENUM
DEF_MESSAGE
DEF_STRUCT
TYPE_BOOL
TYPE_BYTE
TYPE_FLOAT
TYPE_INT
TYPE_STRING
TYPE_UINT