pub async fn do_work(&mut self, work: Work) {
        if work.extract_early() {
            self.try_jump_extraction_queue();
        }

        match &mut self.state {
            Extracting(f) => {
                let b = (&mut f.fut).await;
                match b {
                    Ok(_) => {
                        self.state = Unscanned;
                        // Since waiting for extraction isn't one of the tracked units of work, we
                        // know for a fact we can try to scan the file now.
                        self.start_scanning(work.load_during_scan()).await
                    }
                    Err(e) => {
                        error!("Failed to extract page {:?}: {}", self, e);
                        self.state = Failed("Failed to extract page.".to_string());
                    }
                }
            }
            Unscanned => self.start_scanning(work.load_during_scan()).await,
            Scanning(f) => {
                assert_ne!(work, Work::Scan);

                let ir = (&mut f.0).await;
                self.state = Scanned(Box::new(ScannedPage::new(self, ir)));
                trace!("Finished scanning {:?}", self);
            }
            Scanned(ip) => ip.do_work(work).await,
            Failed(_) => unreachable!(),
        }
    }
// These functions should return after each unit of work is done.
These functions should return after each unit of work is done.
These functions should return after each unit of work is done .
pub async fn do_work(&mut self, work: Work) {
        if work.extract_early() {
            self.try_jump_extraction_queue();
        }
        match &mut self.state {
            Extracting(f) => {
                let b = (&mut f.fut).await;
                match b {
                    Ok(_) => {
                        self.state = Unscanned;
                        // Since waiting for extraction isn't one of the tracked units of work, we
                        // know for a fact we can try to scan the file now.
                        self.start_scanning(work.load_during_scan()).await
                    }
                    Err(e) => {
                        error!("Failed to extract page {:?}: {}", self, e);
                        self.state = Failed("Failed to extract page.".to_string());
                    }
                }
            }
            Unscanned => self.start_scanning(work.load_during_scan()).await,
            Scanning(f) => {
                assert_ne!(work, Work::Scan);
                let ir = (&mut f.0).await;
                self.state = Scanned(Box::new(ScannedPage::new(self, ir)));
                trace!("Finished scanning {:?}", self);
            }
            Scanned(ip) => ip.do_work(work).await,
            Failed(_) => unreachable!(),
        }
    }
pub async fn do_work ( & mut self , work : Work ) { if work . extract_early ( ) { self . try_jump_extraction_queue ( ) ; } match & mut self . state { Extracting ( f ) => { let b = ( & mut f . fut ) . await ; match b { Ok ( _ ) => { self . state = Unscanned ; // Since waiting for extraction isn't one of the tracked units of work, we // know for a fact we can try to scan the file now. self . start_scanning ( work . load_during_scan ( ) ) . await } Err ( e ) => { error ! ( " " self e ) ; self . state = Failed ( " " . to_string ( ) ) ; } } } Unscanned => self . start_scanning ( work . load_during_scan ( ) ) . await , Scanning ( f ) => { assert_ne ! ( work Work Scan ) ; let ir = ( & mut f . 0 ) . await ; self . state = Scanned ( Box :: new ( ScannedPage :: new ( self , ir ) ) ) ; trace ! ( " " self ) ; } Scanned ( ip ) => ip . do_work ( work ) . await , Failed ( _ ) => unreachable ! ( ) , } }
These functions should return after each unit of work is done.
These functions should return after each unit of work is done .
&mut self
work
Work
&mut self
work
Work