fn fetch_waiting(&mut self) -> Result<()> {
        debug!("self.waiting.len() = {}", self.waiting.len());
        debug!(
            "self.send_to_fetcher.is_full() = {}",
            self.send_to_fetcher.is_full()
        );
        while !self.waiting.is_empty() && !self.send_to_fetcher.is_full() {
            trace!("Track fetcher is ready");
            if let Some(mut track) = self.waiting.pop_front() {
                let request = FetchRequest::try_from(&track)?;
                trace!(
                    "Sending a track for fetching with audio url {:?}",
                    &request.uri
                );
                // If the track is already being fetched from an earlier request,
                // we quietly drop this request
                if self.in_work.contains_key(&request.track_token) {
                    trace!("Cache collision!");
                    continue;
                }
                // If the track already exists in the cache, we just move it straight
                // into the ready queue
                if PathBuf::from(&request.path).exists() {
                    trace!("Cache hit!");
                    track.optional.insert(
                        String::from("cached"),
                        serde_json::value::Value::String(request.path),
                    );
                    self.ready.push(track);
                    continue;
                }
                trace!("Cache miss!");
                self.send_to_fetcher.send(request)?;
                self.in_work.insert(track.track_token.clone(), track);
                trace!("Track is being fetched");
            }
        }
        Ok(())
    }
// If there are no tracks currently being fetched, but there are tracks
// waiting to be fetched, send another track to the fetcher
If there are no tracks currently being fetched, but there are tracks
waiting to be fetched, send another track to the fetcher
If there are no tracks currently being fetched but there are tracks waiting to be fetched send another track to the fetcher
fn fetch_waiting(&mut self) -> Result<()> {
        debug!("self.waiting.len() = {}", self.waiting.len());
        debug!(
            "self.send_to_fetcher.is_full() = {}",
            self.send_to_fetcher.is_full()
        );
        while !self.waiting.is_empty() && !self.send_to_fetcher.is_full() {
            trace!("Track fetcher is ready");
            if let Some(mut track) = self.waiting.pop_front() {
                let request = FetchRequest::try_from(&track)?;
                trace!(
                    "Sending a track for fetching with audio url {:?}",
                    &request.uri
                );
                // If the track is already being fetched from an earlier request,
                // we quietly drop this request
                if self.in_work.contains_key(&request.track_token) {
                    trace!("Cache collision!");
                    continue;
                }
                // If the track already exists in the cache, we just move it straight
                // into the ready queue
                if PathBuf::from(&request.path).exists() {
                    trace!("Cache hit!");
                    track.optional.insert(
                        String::from("cached"),
                        serde_json::value::Value::String(request.path),
                    );
                    self.ready.push(track);
                    continue;
                }
                trace!("Cache miss!");
                self.send_to_fetcher.send(request)?;
                self.in_work.insert(track.track_token.clone(), track);
                trace!("Track is being fetched");
            }
        }
        Ok(())
    }
fn fetch_waiting ( & mut self ) -> Result < ( ) > { debug ! ( " " self waiting len ( ) ) ; debug ! ( " " self send_to_fetcher is_full ( ) ) ; while ! self . waiting . is_empty ( ) && ! self . send_to_fetcher . is_full ( ) { trace ! ( " " ) ; if let Some ( mut track ) = self . waiting . pop_front ( ) { let request = FetchRequest :: try_from ( & track ) ? ; trace ! ( " " request uri ) ; // If the track is already being fetched from an earlier request, // we quietly drop this request if self . in_work . contains_key ( & request . track_token ) { trace ! ( " " ) ; continue ; } // If the track already exists in the cache, we just move it straight // into the ready queue if PathBuf :: from ( & request . path ) . exists ( ) { trace ! ( " " ) ; track . optional . insert ( String :: from ( " " ) , serde_json :: value :: Value :: String ( request . path ) , ) ; self . ready . push ( track ) ; continue ; } trace ! ( " " ) ; self . send_to_fetcher . send ( request ) ? ; self . in_work . insert ( track . track_token . clone ( ) , track ) ; trace ! ( " " ) ; } } Ok ( ( ) ) }
If there are no tracks currently being fetched, but there are tracks
waiting to be fetched, send another track to the fetcher
If there are no tracks currently being fetched but there are tracks waiting to be fetched send another track to the fetcher
&mut self
&mut self