(&self, udid: &str, filters: &LogFilters, limit: usize)
| 126 | } |
| 127 | |
| 128 | pub async fn snapshot(&self, udid: &str, filters: &LogFilters, limit: usize) -> Vec<LogEntry> { |
| 129 | let state = { |
| 130 | let streams = self.streams.lock().await; |
| 131 | streams.get(udid).cloned() |
| 132 | }; |
| 133 | let Some(state) = state else { |
| 134 | return Vec::new(); |
| 135 | }; |
| 136 | |
| 137 | let entries = state.entries.lock().await; |
| 138 | let mut matching: Vec<LogEntry> = entries |
| 139 | .iter() |
| 140 | .filter(|entry| log_entry_matches(entry, filters)) |
| 141 | .cloned() |
| 142 | .collect(); |
| 143 | if matching.len() > limit { |
| 144 | matching = matching.split_off(matching.len() - limit); |
| 145 | } |
| 146 | matching |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | fn spawn_log_stream_process(udid: &str) -> Result<Child, AppError> { |
no test coverage detected