Compare commits

..

3 Commits

Author SHA1 Message Date
41c615b03a rename variable to make more sense 2026-03-03 14:26:30 -06:00
b21e3ce71f add app, ui modules 2026-03-03 14:22:14 -06:00
e73ba7f33f add ability to format Row correctly 2026-03-03 14:17:12 -06:00
4 changed files with 32 additions and 6 deletions

0
src/app.rs Normal file
View File

View File

@@ -13,6 +13,8 @@ pub struct Row {
} }
impl Row { impl Row {
const DF: &str = "%Y-%m-%d %H:%M";
pub fn new( pub fn new(
name: &str, name: &str,
hut_type: &str, hut_type: &str,
@@ -50,15 +52,15 @@ impl Row {
fn make_checksum() -> String { fn make_checksum() -> String {
let base = rand::random_range(10000..99999).to_string(); let base = rand::random_range(10000..99999).to_string();
let expect = "a valid character in the base checksum"; let split_expect = "a valid character in the base checksum";
let split = format!( let split = format!(
"{}{}{}{}{}", "{}{}{}{}{}",
base.chars().next().expect(expect), base.chars().next().expect(split_expect),
base.chars().nth(2).expect(expect), base.chars().nth(2).expect(split_expect),
base.chars().nth(4).expect(expect), base.chars().nth(4).expect(split_expect),
base.chars().nth(1).expect(expect), base.chars().nth(1).expect(split_expect),
base.chars().nth(3).expect(expect) base.chars().nth(3).expect(split_expect)
) )
.repeat(2); .repeat(2);
@@ -71,3 +73,25 @@ fn make_checksum() -> String {
format!("{}{}", base, last) format!("{}{}", base, last)
} }
impl std::fmt::Display for Row {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{},{},{},{},{},N,{},{},{},{},{},{},{},{}",
self.name,
self.name,
self.hut_type,
self.path,
self.tare,
self.mat_id,
self.quantity,
self.lot_id,
self.uom,
self.lot_status,
self.born.format(Self::DF),
self.born.format(Self::DF),
self.expire.format(Self::DF),
)
}
}

View File

@@ -1,4 +1,6 @@
mod app;
mod csv; mod csv;
mod ui;
fn main() { fn main() {
println!("Hello, world!"); println!("Hello, world!");

0
src/ui.rs Normal file
View File