GitXplorerGitXplorer
r

gcd-rs

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
efa1565e715d67333997bc982cb7375b32fc8e03

add licence

rrbran committed 3 years ago
Unverified
f893603d851b8bde65847075c2751a9cca2a67cb

fix the Descriptor encode/decode interface

rrbran committed 3 years ago
Unverified
75084264b5800391d8bfb6b889930f9c28e0e81a

bump version

rrbran committed 3 years ago
Unverified
ed898f765db97c548b156eb49cc5d117356c4d63

add iter_mut on DescriptorRecord

rrbran committed 3 years ago
Unverified
49c0b31da1b6a6beb70280e7e2bc1c2b84ea535c

update package name to better reflect the crate name

rrbran committed 3 years ago
Unverified
1a70a9b359551f5a39cf4c482f58839221cb9f09

Added meta data

rrbran committed 3 years ago

README

The README file for this repository.

GCD Prarser and Composer

This lib helps read/write GCD files.

Reading GCD Files

use std::env;
use std::fs::File;
use gcd_rs::parser::Parser;
use gcd_rs::Record;

fn main() {
    //open the gcd file
    let file = File::open("in_file.gcd").unwrap();

    //parser
    let mut parser: Parser<File> = Parser::new(file).unwrap();

    loop {
        //read and print the record until the End is received
        let record = parser.read_record().expect("Unable to read record");
        println!("Record {}", record);
        if let Record::End = record {
            break;
        }
    }
}

Writing GCD File

use gcd_rs::composer::Composer;
use gcd_rs::record::text::TextRecord;
use gcd_rs::Record;
use std::env;
use std::fs::File;

fn main() {
    //create the gcd file
    let file = File::create("out_file.gcd").unwrap();

    //composer
    let mut composer: Composer<File> = Composer::new(file).unwrap();

    //write a text record
    composer
        .write_record(&Record::Text(TextRecord::Simple(
            "Sample File".to_string(),
        )))
        .unwrap();
    //write the end record
    composer.write_record(&Record::End).unwrap();
}