55bca92691
Core features: - Class 1 T.30 protocol: full send/receive implementation - HDLC: DLE-stuffing, FCS strip, USR5637 bit-reversal handling - T.4 MH encoder/decoder (1728px A4 standard) - Document pipeline: PDF (Ghostscript), PNG, TIFF input - Width clamping: US Letter 1734px → 1728px fax standard - Cover page: CJK rasterization (TW/CN/JP/EN), TIFF + HTML output - OCR verification: Tesseract 5 with eng+chi_tra, CJK space-tolerant - API server (axum): health, send, jobs, cover, retry, cancel - Background worker: auto-poll queue, speed fallback, retry policy - Modem detection, pool management Real-world test results (2026-07-23): - V90 → 25153038: 4 pages, V.17 12000 bps, 2:33 ✅ - USR5637 → 25153038: 4 pages, V.17 12000 bps, 2:26 ✅ - Both faxes confirmed received on remote machine Tested: loopback (100% pixel match), multi-page, all input formats, cover pages, OCR verify, API endpoints, worker processing. 13 unit tests pass, 0 new clippy warnings.
59 lines
1.3 KiB
Rust
59 lines
1.3 KiB
Rust
use crate::fax::negotiate::DataRate;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct SpeedFallback {
|
|
rates: Vec<DataRate>,
|
|
current_index: usize,
|
|
}
|
|
|
|
impl Default for SpeedFallback {
|
|
fn default() -> Self {
|
|
Self {
|
|
rates: vec![
|
|
DataRate::V17_14400,
|
|
DataRate::V17_12000,
|
|
DataRate::V29_9600,
|
|
DataRate::V29_7200,
|
|
DataRate::V27ter4800,
|
|
],
|
|
current_index: 0,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl SpeedFallback {
|
|
pub fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
pub fn current_rate(&self) -> DataRate {
|
|
self.rates[self.current_index]
|
|
}
|
|
|
|
pub fn lower_speed(&mut self) -> Option<DataRate> {
|
|
if self.current_index + 1 < self.rates.len() {
|
|
self.current_index += 1;
|
|
Some(self.rates[self.current_index])
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
|
|
pub fn reset(&mut self) {
|
|
self.current_index = 0;
|
|
}
|
|
|
|
pub fn is_min_speed(&self) -> bool {
|
|
self.current_index == self.rates.len() - 1
|
|
}
|
|
|
|
pub fn set_initial_rate(&mut self, rate: DataRate) {
|
|
for (i, r) in self.rates.iter().enumerate() {
|
|
if *r == rate {
|
|
self.current_index = i;
|
|
return;
|
|
}
|
|
}
|
|
self.current_index = 0;
|
|
}
|
|
} |