[][src]Crate iffc

IFF is a binary-interchange format developed by Electronic Arts for tagging binary data with a meaning. This file is made of out of segments referred to as so called "chunks". This format is used for mainly storing multimedia, eg. audio: WAVE, video: AVI, midi: RMI, images: TIFF.

This crate provides data-structures and wrappers to manipulate this format quite easily by reading or writing into file-streams.

Decoding is done with iterators and Encoding is done with a fancy operator: << shift left. Some basic syntax to work this library is shown below.

Examples

To decode all the chunks avialable from the given reader:

use iffc::Decoder;
 
fn main() {
    let inp = std::io::Cursor::new(b"RIFF\x04\x00\x00\x00WAVE");
    let parser = Decoder(Box::new(inp));
 
    for chk in inp
    { println!("{:?}: {}", chk.0, chk.1.len()); }
}

To encode chunks into a given writer:

use iffc::{Encoder, Chunk};
 
fn main() {
    let out = std::io::Cursor::new(Vec::new());
    let deparser = Encoder(Box::new(out));
 
    deparser << Chunk(*b"RIFF", b"WAVE".to_vec());
}

Structs

Chunk

An IFF chunk represents a single segment of a complete IFF file. Note: Even though this structure is capable of stroing data upto usize but IFF limits that to u32 only.

Decoder

A structure which wraps a reader and parses IFF chunks and behaves like an iterator which yields IFFChunk until an entire-chunk can't be constructed.

Encoder

A structure which wraps a writer and writes IFF chunks to it, by using << (shift-left) with an RHS of type IFFChunk, also that operand can be chained.