added fields to the traits

This commit is contained in:
filipriec
2025-03-30 18:33:21 +02:00
parent 0568441e46
commit 12aec72141
2 changed files with 9 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ pub trait CanvasState {
fn inputs(&self) -> Vec<&String>; fn inputs(&self) -> Vec<&String>;
fn get_current_input(&self) -> &str; fn get_current_input(&self) -> &str;
fn get_current_input_mut(&mut self) -> &mut String; 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) // Implement for FormState (keep existing form.rs code and add this)
@@ -41,4 +42,8 @@ impl CanvasState for FormState {
.get_mut(self.current_field) .get_mut(self.current_field)
.expect("Invalid current_field index") .expect("Invalid current_field index")
} }
fn fields(&self) -> Vec<&str> {
self.fields.iter().map(|s| s.as_str()).collect()
}
} }

View File

@@ -57,4 +57,8 @@ impl CanvasState for AuthState {
_ => panic!("Invalid current_field index in AuthState"), _ => panic!("Invalid current_field index in AuthState"),
} }
} }
fn fields(&self) -> Vec<&str> {
vec!["Username/Email", "Password"]
}
} }