.iter()
.enumerate()
.skip_while(|(_, b)| **b == FEND)
- .skip(1)
- .next()
+ .nth(1)
.ok_or(KissError::MalformedKissFrame)?
.0;
let end = self.data[start..]
.iter()
.enumerate()
- .skip_while(|(_, b)| **b != FEND)
- .next()
+ .find(|(_, b)| **b == FEND)
.ok_or(KissError::MalformedKissFrame)?
.0
+ start;
/// Return the header byte of the KISS frame, skipping over 0 or more prepended FENDs.
fn header_byte(&self) -> Result<u8, KissError> {
- Ok(self
- .data
+ self.data
.iter()
- .skip_while(|b| **b == FEND)
- .next()
+ .find(|b| **b != FEND)
.cloned()
- .ok_or(KissError::MalformedKissFrame)?)
+ .ok_or(KissError::MalformedKissFrame)
}
}
}
}
+impl Default for KissBuffer {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum KissError {
MalformedKissFrame,
}
}
+impl Default for SoftModulator {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
#[derive(Debug)]
pub(crate) struct DecodeCandidate {
burst: SyncBurst,
}
pub fn set_destination(&mut self, destination: &Address) {
- self.0[0..6].copy_from_slice(&encode_address(&destination));
+ self.0[0..6].copy_from_slice(&encode_address(destination));
self.recalculate_crc();
}
pub fn set_source(&mut self, source: &Address) {
- self.0[6..12].copy_from_slice(&encode_address(&source));
+ self.0[6..12].copy_from_slice(&encode_address(source));
self.recalculate_crc();
}
bits.set_bit(12 * 8 + 5, (number >> 3) & 1);
bits.set_bit(12 * 8 + 6, (number >> 2) & 1);
bits.set_bit(12 * 8 + 7, (number >> 1) & 1);
- bits.set_bit(13 * 8 + 0, number & 1);
+ bits.set_bit(13 * 8, number & 1);
self.recalculate_crc();
}
pub fn set_now(&mut self, now_samples: u64) {
self.now = now_samples;
- match self.state {
- State::TxEndingAtTime(time) => {
- if now_samples >= time {
- self.ptt = false;
- self.state = State::Idle;
- }
+ if let State::TxEndingAtTime(time) = self.state {
+ if now_samples >= time {
+ self.ptt = false;
+ self.state = State::Idle;
}
- _ => (),
}
}
pub fn set_tx_end_time(&mut self, in_samples: usize) {
log::debug!("tnc has been told that tx will complete in {in_samples} samples");
- match self.state {
- State::TxEnding => {
- self.state = State::TxEndingAtTime(self.now + in_samples as u64);
- }
- _ => (),
+ if let State::TxEnding = self.state {
+ self.state = State::TxEndingAtTime(self.now + in_samples as u64);
}
}
pending.app_data[len..len + 2].copy_from_slice(&packet_crc.to_be_bytes());
pending.app_data_len = len + 2;
pending.lsf = Some(LsfFrame::new_packet(
- &Address::Callsign(Callsign(b"M17RT-PKT".clone())),
+ &Address::Callsign(Callsign(*b"M17RT-PKT")),
&Address::Broadcast,
));
self.packet_queue[self.packet_next] = pending;
}
}
+impl Default for SoftTnc {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum SoftTncError {
General(&'static str),