reader/writer rename
This commit is contained in:
parent
d77e164d07
commit
61587132a3
11
src/main.rs
11
src/main.rs
@ -279,7 +279,8 @@ struct WriteQueueItem {
|
|||||||
|
|
||||||
type WriteQueue = Arc<Mutex<VecDeque<Option<WriteQueueItem>>>>;
|
type WriteQueue = Arc<Mutex<VecDeque<Option<WriteQueueItem>>>>;
|
||||||
|
|
||||||
async fn data_reader(queue: WriteQueue) {
|
/// read txt files from zip and convert to json
|
||||||
|
async fn reader_converter(queue: WriteQueue) {
|
||||||
// open archive just to list files
|
// open archive just to list files
|
||||||
let archive = ZipFileReader::new(String::from(INPUT_FILENAME))
|
let archive = ZipFileReader::new(String::from(INPUT_FILENAME))
|
||||||
.await
|
.await
|
||||||
@ -315,7 +316,9 @@ async fn data_reader(queue: WriteQueue) {
|
|||||||
println!("convert done ✅");
|
println!("convert done ✅");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn data_writer(queue: WriteQueue) {
|
|
||||||
|
/// write json data to zip files
|
||||||
|
async fn zip_writer(queue: WriteQueue) {
|
||||||
let mut file = fs::File::create(OUTPUT_FILENAME).await.unwrap();
|
let mut file = fs::File::create(OUTPUT_FILENAME).await.unwrap();
|
||||||
let mut writer = ZipFileWriter::new(&mut file);
|
let mut writer = ZipFileWriter::new(&mut file);
|
||||||
|
|
||||||
@ -370,8 +373,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let queue_w = Arc::clone(&queue);
|
let queue_w = Arc::clone(&queue);
|
||||||
|
|
||||||
tokio::try_join!(
|
tokio::try_join!(
|
||||||
tokio::spawn(data_reader(queue_r)),
|
tokio::spawn(reader_converter(queue_r)),
|
||||||
tokio::spawn(data_writer(queue_w))
|
tokio::spawn(zip_writer(queue_w))
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
println!("all done ✅");
|
println!("all done ✅");
|
||||||
|
Loading…
Reference in New Issue
Block a user