-
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
1 parent
eb3dd11
commit 7f6ce12
Showing
2 changed files
with
36 additions
and
0 deletions.
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,31 @@ | ||
use base64::{self, Engine}; | ||
use serde::Deserialize; | ||
use std::fs; | ||
use std::time::Duration; | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct Wisdom { | ||
description: String, | ||
} | ||
|
||
pub async fn worker_thread() { | ||
loop { | ||
let base64_string = fs::read_to_string("encoded-wisdoms.b64") | ||
.expect("Failed to read encoded-wisdoms.b64 file") | ||
.replace(['\n','\r'], ""); | ||
|
||
dbg!(&base64_string); | ||
|
||
let decoded_bytes = base64::prelude::BASE64_STANDARD.decode(base64_string) | ||
.expect("Failed to decode base64 string"); | ||
|
||
let wisdoms: Vec<Wisdom> = | ||
serde_json::from_slice(&decoded_bytes).expect("Failed to parse JSON"); | ||
|
||
for wisdom in wisdoms { | ||
println!("Decoded wisdom: {:?}", wisdom); | ||
} | ||
|
||
tokio::time::sleep(Duration::from_secs(1)).await; | ||
} | ||
} |