serde-pod (plain old data)

Реализует простую сериализацию и десериализацию структур, наиболее близкую к их представлению в памяти.

Пример

Читаем заголовок GFF файла (формат Bioware, используемый для хранения данных в таких играх, как Neverwinter Nights, Neverwinter Nights 2 и Ведьмак):

```rust extern crate byteorder;

[macro_use]

extern crate serdederive; extern crate serdepod; use serdepod::{frombytes, Result};

[derive(Debug, Deserialize, PartialEq)]

struct Signature([u8; 4]);

[derive(Debug, Deserialize, PartialEq)]

struct Version([u8; 4]);

[derive(Debug, Deserialize, PartialEq)]

struct Section { offset: u32, count: u32, }

[derive(Debug, Deserialize, PartialEq)]

struct GffHeader { signature: Signature, version: Version, structs: Section, fields: Section, labels: Section, fielddata: Section, fieldindices: Section, list_indices: Section, }

fn main() { let header: GffHeader = frombytes::(&[ // Signature 0x47, 0x55, 0x49, 0x20, // Version 0x56, 0x33, 0x2E, 0x32, // structs 0x38, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, // fields 0xEC, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, // labels 0xD0, 0x07, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, // fielddata 0x70, 0x09, 0x00, 0x00, 0x1D, 0x02, 0x00, 0x00, // fieldindices 0x8D, 0x0B, 0x00, 0x00, 0x4C, 0x02, 0x00, 0x00, // listindices 0xD9, 0x0D, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, ])?;

asserteq!(header, GffHeader { signature: Signature(*b"GUI "), version: Version(*b"V3.2"), structs: Section { offset: 0x38, count: 15 }, fields: Section { offset: 0xEC, count: 147 }, labels: Section { offset: 0x07D0, count: 26 }, fielddata: Section { offset: 0x0970, count: 541 }, fieldindices: Section { offset: 0x0B8D, count: 588 }, listindices: Section { offset: 0x0DD9, count: 36 }, }); } ```