-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Quirky Binder - CSV | ||
|
||
`quirky_binder_csv` helps reading and writing CSV files. | ||
|
||
## Setup | ||
|
||
* add `quirky_binder_csv` to `[build-dependencies]` | ||
* add `csv = "1"` to `[dependencies]` | ||
|
||
## Read | ||
|
||
``` | ||
use quirky_binder_csv::read_csv; | ||
{ | ||
( | ||
read_csv( | ||
input_file: "input/hello_universe.csv", | ||
fields: [("hello", "String"), ("universe", "usize")], | ||
has_headers: true, | ||
) | ||
- ... | ||
) | ||
} | ||
``` | ||
|
||
## Write | ||
|
||
``` | ||
use quirky_binder_csv::write_csv; | ||
{ | ||
( | ||
... | ||
- write_csv( | ||
output_file: "output/hello_universe.csv", | ||
has_headers: true, | ||
) | ||
) | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"csv", | ||
"hello_world", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "csv" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
csv = "1" | ||
fallible-iterator = "0.3" | ||
quirky_binder_support = { path = "../../quirky_binder_support" } | ||
serde = "1" | ||
static_assertions = "1" | ||
truc_runtime = { git = "https://github.com/arnodb/truc.git" } | ||
|
||
# quirky_binder_monitor | ||
chrono = { version = "0.4", optional = true } | ||
self-meter = { version = "0.6", optional = true } | ||
tracking-allocator = { version = "0.4", optional = true } | ||
|
||
[features] | ||
default = [] | ||
quirky_binder_monitor = ["chrono", "self-meter", "tracking-allocator"] | ||
|
||
[build-dependencies] | ||
handlebars = "4" | ||
quirky_binder = { path = "../../quirky_binder" } | ||
quirky_binder_csv = { path = "../../contrib/quirky_binder_csv" } | ||
quirky_binder_lang = { path = "../../quirky_binder_lang" } | ||
serde = { version = "1", features = ["derive"] } | ||
truc = { git = "https://github.com/arnodb/truc.git" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Quirky Binder Recipe - csv | ||
|
||
## Description | ||
|
||
Quirky Binder allows reading and writing CSV files with the help of `quirky_binder_csv` crate. | ||
|
||
## Setup | ||
|
||
In addition to mandatory quirky binder dependencies: | ||
|
||
* add `quirky_binder_csv` to `[build-dependencies]` | ||
* add `csv` to `[dependencies]` (see `quirky_binder_csv` documentation) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::path::Path; | ||
|
||
use quirky_binder::{prelude::*, quirky_binder}; | ||
use truc::record::type_resolver::{StaticTypeResolver, TypeResolver}; | ||
|
||
fn main() { | ||
quirky_binder!(include("main.qb")); | ||
|
||
let type_resolver = { | ||
let mut resolver = StaticTypeResolver::new(); | ||
resolver.add_std_types(); | ||
resolver | ||
}; | ||
|
||
let graph = quirky_binder_main(GraphBuilder::new( | ||
&type_resolver, | ||
ChainCustomizer::default(), | ||
)) | ||
.unwrap_or_else(|err| { | ||
panic!("{}", err); | ||
}); | ||
|
||
let out_dir = std::env::var("OUT_DIR").unwrap(); | ||
graph.generate(Path::new(&out_dir)).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
hello,universe | ||
world,42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use quirky_binder_csv::{read_csv, write_csv}; | ||
|
||
{ | ||
( | ||
read_csv( | ||
input_file: "input/hello_universe.csv", | ||
fields: [("hello", "String"), ("universe", "usize")], | ||
has_headers: true, | ||
) | ||
- write_csv( | ||
output_file: "output/hello_universe.csv", | ||
has_headers: true, | ||
) | ||
) | ||
} | ||
|
||
#( | ||
name: "quirky_binder_monitor", | ||
feature: "quirky_binder_monitor", | ||
) | ||
{ ( quirky_binder::filter::monitor::monitor() ) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use quirky_binder_support::chain::configuration::ChainConfiguration; | ||
|
||
#[macro_use] | ||
extern crate static_assertions; | ||
|
||
#[allow(dead_code)] | ||
#[allow(clippy::borrowed_box)] | ||
#[allow(clippy::module_inception)] | ||
mod chain { | ||
include!(concat!(env!("OUT_DIR"), "/chain.rs")); | ||
} | ||
|
||
quirky_binder_support::tracking_allocator_static!(); | ||
|
||
#[quirky_binder_support::tracking_allocator_main] | ||
fn main() { | ||
chain::main(ChainConfiguration::default()).unwrap(); | ||
} |