Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbran/gcd-rs
https://github.com/rbran/gcd-rs
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rbran/gcd-rs
- Owner: rbran
- License: mit
- Created: 2021-09-29T17:04:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-03T20:37:24.000Z (over 2 years ago)
- Last Synced: 2024-10-13T01:05:23.844Z (24 days ago)
- Language: Rust
- Size: 24.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GCD Prarser and Composer
This lib helps read/write GCD files.
## Reading GCD Files
```rust
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 = 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
```rust
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 = 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();
}```