pub fn cancel(&mut self, root: QueryId) -> bool {
        let query = if let Some(query) = self.queries.remove(&root) {
            query
        } else {
            return false;
        };
        let queries = &self.queries;
        self.events.retain(|event| {
            let (id, req) = match event {
                QueryEvent::Request(id, req) => (id, req),
                QueryEvent::Progress(id, _) => return *id != root,
                QueryEvent::Complete(_, _) => return true,
            };
            if queries.get(id).map(|q| q.hdr.root) != Some(root) {
                return true;
            }
            tracing::trace!("{} {} {} cancel", root, id, req);
            false
        });
        match query.state {
            State::Get(_) => {
                tracing::trace!("{} {} get cancel", root, root);
                true
            }
            State::Sync(state) => {
                for id in state.missing {
                    tracing::trace!("{} {} get cancel", root, id);
                    self.queries.remove(&id);
                }
                tracing::trace!("{} {} sync cancel", root, root);
                true
            }
            State::None => {
                self.queries.insert(root, query);
                false
            }
        }
    }
/// Cancels an in progress query.
Cancels an in progress query.
Cancels an in progress query .
pub fn cancel(&mut self, root: QueryId) -> bool {
        let query = if let Some(query) = self.queries.remove(&root) {
            query
        } else {
            return false;
        };
        let queries = &self.queries;
        self.events.retain(|event| {
            let (id, req) = match event {
                QueryEvent::Request(id, req) => (id, req),
                QueryEvent::Progress(id, _) => return *id != root,
                QueryEvent::Complete(_, _) => return true,
            };
            if queries.get(id).map(|q| q.hdr.root) != Some(root) {
                return true;
            }
            tracing::trace!("{} {} {} cancel", root, id, req);
            false
        });
        match query.state {
            State::Get(_) => {
                tracing::trace!("{} {} get cancel", root, root);
                true
            }
            State::Sync(state) => {
                for id in state.missing {
                    tracing::trace!("{} {} get cancel", root, id);
                    self.queries.remove(&id);
                }
                tracing::trace!("{} {} sync cancel", root, root);
                true
            }
            State::None => {
                self.queries.insert(root, query);
                false
            }
        }
    }
pub fn cancel ( & mut self , root : QueryId ) -> bool { let query = if let Some ( query ) = self . queries . remove ( & root ) { query } else { return false ; } ; let queries = & self . queries ; self . events . retain ( | event | { let ( id , req ) = match event { QueryEvent :: Request ( id , req ) => ( id , req ) , QueryEvent :: Progress ( id , _ ) => return * id != root , QueryEvent :: Complete ( _ , _ ) => return true , } ; if queries . get ( id ) . map ( | q | q . hdr . root ) != Some ( root ) { return true ; } tracing :: trace ! ( " " root id req ) ; false } ) ; match query . state { State :: Get ( _ ) => { tracing :: trace ! ( " " root root ) ; true } State :: Sync ( state ) => { for id in state . missing { tracing :: trace ! ( " " root id ) ; self . queries . remove ( & id ) ; } tracing :: trace ! ( " " root root ) ; true } State :: None => { self . queries . insert ( root , query ) ; false } } }
Cancels an in progress query.
Cancels an in progress query .
&mut self
root
QueryId
&mut self
root
QueryId