fn sync_query<F>(&mut self, id: QueryId, f: F)
    where
        F: FnOnce(&mut Self, &Header, SyncState) -> Transition<SyncState, Result<(), Cid>>,
    {
        if let Some(mut parent) = self.queries.remove(&id) {
            let state = if let State::Sync(state) = parent.state {
                state
            } else {
                return;
            };
            match f(self, &parent.hdr, state) {
                Transition::Next(state) => {
                    parent.state = State::Sync(state);
                    self.queries.insert(id, parent);
                }
                Transition::Complete(res) => {
                    if res.is_ok() {
                        tracing::trace!("{} {} sync ok", parent.hdr.root, parent.hdr.id);
                    } else {
                        tracing::trace!("{} {} sync err", parent.hdr.root, parent.hdr.id);
                    }
                    self.recv_sync(parent.hdr, res);
                }
            }
        }
    }
/// Advances a sync query state machine using a transition function.
Advances a sync query state machine using a transition function.
Advances a sync query state machine using a transition function .
fn sync_query<F>(&mut self, id: QueryId, f: F)
    where
        F: FnOnce(&mut Self, &Header, SyncState) -> Transition<SyncState, Result<(), Cid>>,
    {
        if let Some(mut parent) = self.queries.remove(&id) {
            let state = if let State::Sync(state) = parent.state {
                state
            } else {
                return;
            };
            match f(self, &parent.hdr, state) {
                Transition::Next(state) => {
                    parent.state = State::Sync(state);
                    self.queries.insert(id, parent);
                }
                Transition::Complete(res) => {
                    if res.is_ok() {
                        tracing::trace!("{} {} sync ok", parent.hdr.root, parent.hdr.id);
                    } else {
                        tracing::trace!("{} {} sync err", parent.hdr.root, parent.hdr.id);
                    }
                    self.recv_sync(parent.hdr, res);
                }
            }
        }
    }
fn sync_query < F > ( & mut self , id : QueryId , f : F ) where F : FnOnce ( & mut Self , & Header , SyncState ) -> Transition < SyncState , Result < ( ) , Cid > > , { if let Some ( mut parent ) = self . queries . remove ( & id ) { let state = if let State :: Sync ( state ) = parent . state { state } else { return ; } ; match f ( self , & parent . hdr , state ) { Transition :: Next ( state ) => { parent . state = State :: Sync ( state ) ; self . queries . insert ( id , parent ) ; } Transition :: Complete ( res ) => { if res . is_ok ( ) { tracing :: trace ! ( " " parent hdr root parent hdr id ) ; } else { tracing :: trace ! ( " " parent hdr root parent hdr id ) ; } self . recv_sync ( parent . hdr , res ) ; } } } }
Advances a sync query state machine using a transition function.
Advances a sync query state machine using a transition function .
&mut self
id
QueryId
f
F
&mut self
id
QueryId
f
F