Skip to main content

parse_progress

Function parse_progress 

Source
pub fn parse_progress(text: &str) -> Option<f32>
Expand description

Parse progress from a text string

Returns progress as a percentage (0.0 to 100.0) or None if no progress detected.

§Safety

This function is safe from ReDoS attacks because:

  • All regex patterns are pre-compiled with lazy_static
  • Patterns have no catastrophic backtracking (no nested quantifiers)
  • Input is limited to reasonable line lengths

§Examples

use bssh::ui::tui::progress::parse_progress;

assert_eq!(parse_progress("Downloading: 78%"), Some(78.0));
assert_eq!(parse_progress("Progress: 45/100"), Some(45.0));
assert_eq!(parse_progress("No progress here"), None);