Migrate #4

Merged
phoenix merged 14 commits from migrate into v1.x 2026-06-06 12:48:59 -04:00
2 changed files with 24 additions and 21 deletions
Showing only changes of commit 183c442fdb - Show all commits
+3 -1
View File
@@ -12,7 +12,9 @@ async fn main() {
let filepath = &args[1];
println!("Filepath: {filepath:?}");
let prsr = parser::NumberParser{filepath: filepath.clone()};
let prsr = parser::NumberParser {
filepath: filepath.clone(),
};
match prsr.file_dump().await {
Ok(contacts) => {
+21 -20
View File
@@ -1,4 +1,4 @@
use std::io::{BufRead};
use std::io::BufRead;
const LETTERS: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -8,7 +8,9 @@ pub struct NumberParser {
}
impl NumberParser {
pub async fn file_dump(&self) -> Result<Vec<textsender_models::contact::Contact>, std::io::Error> {
pub async fn file_dump(
&self,
) -> Result<Vec<textsender_models::contact::Contact>, std::io::Error> {
println!("Dumping files");
let mut objs: Vec<textsender_models::contact::Contact> = Vec::new();
@@ -34,9 +36,7 @@ impl NumberParser {
Ok(removed_duplicates)
}
Err(err) => {
Err(err)
}
Err(err) => Err(err),
}
}
@@ -44,16 +44,14 @@ impl NumberParser {
let filename = String::from("numbers.json");
match serde_json::to_string(&numbers) {
Ok(json_string) => {
match std::fs::write(&filename, json_string) {
Ok(_) => {
println!("Saved to: {filename:?}");
}
Err(err) => {
eprintln!("Error: {err:?}");
}
Ok(json_string) => match std::fs::write(&filename, json_string) {
Ok(_) => {
println!("Saved to: {filename:?}");
}
}
Err(err) => {
eprintln!("Error: {err:?}");
}
},
Err(err) => {
eprintln!("Error: {err:?}");
}
@@ -76,13 +74,14 @@ impl NumberParser {
let reader = std::io::BufReader::new(file);
reader.lines().collect()
}
Err(err) => {
Err(err)
}
Err(err) => Err(err),
}
}
async fn remove_dups(&self, contacts: &Vec<textsender_models::contact::Contact>) -> Vec<textsender_models::contact::Contact> {
async fn remove_dups(
&self,
contacts: &Vec<textsender_models::contact::Contact>,
) -> Vec<textsender_models::contact::Contact> {
let mut unique_contacts: Vec<textsender_models::contact::Contact> = Vec::new();
let mut unique_items = std::collections::HashSet::new();
@@ -100,9 +99,11 @@ impl NumberParser {
unique_contacts
}
async fn update_contacts(&self, contacts: &Vec<textsender_models::contact::Contact>) -> Vec<textsender_models::contact::Contact> {
async fn update_contacts(
&self,
contacts: &Vec<textsender_models::contact::Contact>,
) -> Vec<textsender_models::contact::Contact> {
let mut updated: Vec<textsender_models::contact::Contact> = Vec::new();
for ct in contacts {