/// Give the sequence number of an ICMP echo reply back to the store. Returns the latency and
/// any possible errors.
Give the sequence number of an ICMP echo reply back to the store. Returns the latency and
any possible errors.
Give the sequence number of an ICMP echo reply back to the store . Returns the latency and any possible errors .
pub fn give(
        &mut self,
        sequence_num: u16,
        offset_from_start_time: Option<zx::Duration>,
    ) -> Result<Option<zx::Duration>, GiveError> {
        let now = fasync::Time::now().into_zx();
        let latency = offset_from_start_time.map(|time| now - self.start_time - time);
        if sequence_num >= self.next_seq {
            return Err(GiveError::DoesNotExist(latency));
        }
        let (expected, _) = self.last_seq.overflowing_add(1);
        if sequence_num == expected {
            self.last_seq = sequence_num;
            Ok(latency)
        } else if sequence_num < expected {
            Err(GiveError::Duplicate(latency))
        } else {
            Err(GiveError::OutOfOrder(latency))
        }
    }
pub fn give ( & mut self , sequence_num : u16 , offset_from_start_time : Option < zx :: Duration > , ) -> Result < Option < zx :: Duration > , GiveError > { let now = fasync :: Time :: now ( ) . into_zx ( ) ; let latency = offset_from_start_time . map ( | time | now - self . start_time - time ) ; if sequence_num >= self . next_seq { return Err ( GiveError :: DoesNotExist ( latency ) ) ; } let ( expected , _ ) = self . last_seq . overflowing_add ( 1 ) ; if sequence_num == expected { self . last_seq = sequence_num ; Ok ( latency ) } else if sequence_num < expected { Err ( GiveError :: Duplicate ( latency ) ) } else { Err ( GiveError :: OutOfOrder ( latency ) ) } }
Give the sequence number of an ICMP echo reply back to the store.
Give the sequence number of an ICMP echo reply back to the store .
&mut self
sequence_num
u16
offset_from_start_time
Option<zx::Duration>