From 12aec72141506ec8cf6cf4da83318f65e3f28198 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sun, 30 Mar 2025 18:33:21 +0200 Subject: [PATCH] added fields to the traits --- client/src/state/canvas_state.rs | 5 +++++ client/src/state/pages/auth.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/client/src/state/canvas_state.rs b/client/src/state/canvas_state.rs index be48f39..7ccb188 100644 --- a/client/src/state/canvas_state.rs +++ b/client/src/state/canvas_state.rs @@ -9,6 +9,7 @@ pub trait CanvasState { fn inputs(&self) -> Vec<&String>; fn get_current_input(&self) -> &str; fn get_current_input_mut(&mut self) -> &mut String; + fn fields(&self) -> Vec<&str>; } // Implement for FormState (keep existing form.rs code and add this) @@ -41,4 +42,8 @@ impl CanvasState for FormState { .get_mut(self.current_field) .expect("Invalid current_field index") } + + fn fields(&self) -> Vec<&str> { + self.fields.iter().map(|s| s.as_str()).collect() + } } diff --git a/client/src/state/pages/auth.rs b/client/src/state/pages/auth.rs index e7eb8ca..f2cc787 100644 --- a/client/src/state/pages/auth.rs +++ b/client/src/state/pages/auth.rs @@ -57,4 +57,8 @@ impl CanvasState for AuthState { _ => panic!("Invalid current_field index in AuthState"), } } + + fn fields(&self) -> Vec<&str> { + vec!["Username/Email", "Password"] + } }