From: Tilman Sauerbeck Date: Thu, 9 Jan 2020 14:14:13 +0000 (+0100) Subject: common: Implement Logger::has_recording(). X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=3ca473a1f602d9f7756243793dbdbc838d7ddfee;p=gps-watch.git common: Implement Logger::has_recording(). --- diff --git a/src/common/logger.rs b/src/common/logger.rs index 2154a01..029cc9a 100644 --- a/src/common/logger.rs +++ b/src/common/logger.rs @@ -570,6 +570,21 @@ impl<'a> Logger<'a> { self.write_buffer_offset += num_bytes_written; } + /// + /// Check whether or not recording @p recording_id exists. + pub fn has_recording(&mut self, recording_id: u16) -> bool { + if recording_id == 0 { + return false; + } + + self.sector_header_iter().find(|&index| { + let sector_header = &self.sector_header[index as usize]; + + sector_header.recording_id == recording_id && + sector_header.starts_recording() + }).is_some() + } + /// /// Retrieve recording @p recording_id and /// write it to @p tx_buf in yencoded form.