| 52 | } |
| 53 | |
| 54 | pub fn topic_details( |
| 55 | &self, |
| 56 | context: RepoId, |
| 57 | ) -> Result<(Vec<RepoTopicWrapper>, RepoTopicWrapper)> { |
| 58 | let mut display_topic: Option<RepoTopicWrapper> = match self.0.get(&context) { |
| 59 | Some(repo_topic) => { |
| 60 | if repo_topic.has_details() { |
| 61 | Some((context, repo_topic).try_into()?) |
| 62 | } else { |
| 63 | None |
| 64 | } |
| 65 | } |
| 66 | None => None, |
| 67 | }; |
| 68 | |
| 69 | let mut topics = vec![]; |
| 70 | |
| 71 | for (&repo_id, object) in self.iter() { |
| 72 | if display_topic.is_none() && object.has_details() { |
| 73 | display_topic = Some((repo_id, object).try_into()?); |
| 74 | } |
| 75 | topics.push((repo_id, object).try_into()?); |
| 76 | } |
| 77 | |
| 78 | if display_topic.is_none() { |
| 79 | return Err(Error::Repo("no display topic".into())); |
| 80 | } |
| 81 | |
| 82 | Ok((topics, display_topic.unwrap())) |
| 83 | } |
| 84 | |
| 85 | pub fn iter(&self) -> std::collections::btree_map::Iter<'_, RepoId, RepoObject> { |
| 86 | self.0.iter() |