implemented lifetimes properly
All checks were successful
/ Quality Check (push) Successful in 1m38s
/ Build (push) Successful in 1m57s

This commit is contained in:
Phani Pavan K
2025-11-02 08:20:44 +05:30
parent 26202cd7d2
commit 7b11193b15
5 changed files with 14 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ use ratatui::{
widgets::{Block, Borders}, widgets::{Block, Borders},
}; };
pub fn entryBox(title: String) -> Block<'static> { pub fn entryBox<'a>(title: &'a str) -> Block<'a> {
Block::default() Block::default()
.title(title) .title(title)
.borders(Borders::ALL) .borders(Borders::ALL)

View File

@@ -9,12 +9,12 @@ use ratatui::{
widgets::{Block, Borders, Cell, Row, Table}, widgets::{Block, Borders, Cell, Row, Table},
}; };
pub fn getTableElement( pub fn getTableElement<'a>(
entries: &[Entry], entries: &'a [Entry],
curScreen: &CurrentScreen, curScreen: &CurrentScreen,
appStatus: &AppStatus, appStatus: &AppStatus,
isHashDifferent: bool, isHashDifferent: bool,
) -> Table<'static> { ) -> Table<'a> {
let headers = ["No.", "From IP", "From Port", "-->", "To IP", "To Port"] let headers = ["No.", "From IP", "From Port", "-->", "To IP", "To Port"]
.into_iter() .into_iter()
.map(Cell::from) .map(Cell::from)

View File

@@ -4,7 +4,7 @@ use ratatui::{
widgets::{Block, Borders, Paragraph, Wrap}, widgets::{Block, Borders, Paragraph, Wrap},
}; };
pub fn getExitPara() -> Paragraph<'static> { pub fn getExitPara<'a>() -> Paragraph<'a> {
let exitPopup = Block::default() let exitPopup = Block::default()
.title("Exit Window") .title("Exit Window")
.borders(Borders::ALL) .borders(Borders::ALL)

View File

@@ -5,7 +5,7 @@ use ratatui::{
use crate::app::status::{AppStatus, CurrentScreen, EditingField, EntryValError}; use crate::app::status::{AppStatus, CurrentScreen, EditingField, EntryValError};
pub fn getHeaderScreen(scr: &CurrentScreen) -> (Color, Span<'static>) { pub fn getHeaderScreen<'a>(scr: &'a CurrentScreen) -> (Color, Span<'a>) {
match scr { match scr {
CurrentScreen::Main => ( CurrentScreen::Main => (
Color::LightBlue, Color::LightBlue,
@@ -30,7 +30,10 @@ pub fn getHeaderScreen(scr: &CurrentScreen) -> (Color, Span<'static>) {
} }
} }
pub fn getHeaderStatus(status: &AppStatus, editingField: &Option<EditingField>) -> Span<'static> { pub fn getHeaderStatus<'a>(
status: &'a AppStatus,
editingField: &'a Option<EditingField>,
) -> Span<'a> {
match status { match status {
AppStatus::Welcome => Span::styled("Welcome", Style::default().fg(Color::White)), AppStatus::Welcome => Span::styled("Welcome", Style::default().fg(Color::White)),
AppStatus::Added => Span::styled("Added", Style::default().fg(Color::Green)), AppStatus::Added => Span::styled("Added", Style::default().fg(Color::Green)),

View File

@@ -94,10 +94,10 @@ pub fn ui(frame: &mut Frame, app: &mut AppState) {
]) ])
.split(area); .split(area);
let mut fromIPBlock = entryBox::entryBox("From IP".to_string()); let mut fromIPBlock = entryBox::entryBox("From IP");
let mut toIPBlock = entryBox::entryBox("To IP".to_string()); let mut toIPBlock = entryBox::entryBox("To IP");
let mut fromPortBlock = entryBox::entryBox("From Port".to_string()); let mut fromPortBlock = entryBox::entryBox("From Port");
let mut toPortBlock = entryBox::entryBox("To Port".to_string()); let mut toPortBlock = entryBox::entryBox("To Port");
let activeStyle = Style::default().bg(Color::LightYellow).fg(Color::Black); let activeStyle = Style::default().bg(Color::LightYellow).fg(Color::Black);
match edit { match edit {