Add some predicates on DesktopEntry
Getty Ritter
7 years ago
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | impl DesktopEntry { |
| 248 | pub fn is_application(&self) -> bool { | |
| 249 | match self.typ { | |
| 250 | EntryType::Application(_) => true, | |
| 251 | _ => false, | |
| 252 | } | |
| 253 | } | |
| 254 | ||
| 255 | pub fn is_directory(&self) -> bool { | |
| 256 | match self.typ { | |
| 257 | EntryType::Directory => true, | |
| 258 | _ => false, | |
| 259 | } | |
| 260 | } | |
| 261 | ||
| 262 | pub fn is_link(&self) -> bool { | |
| 263 | match self.typ { | |
| 264 | EntryType::Link(_) => true, | |
| 265 | _ => false, | |
| 266 | } | |
| 267 | } | |
| 268 | ||
| 248 | 269 | pub fn from_file<R: Read>(reader: &mut R) -> Result<DesktopEntry, Error> { |
| 249 | 270 | let mut bags = parser::bags_from_file(reader)?; |
| 250 | 271 | DesktopEntry::from_bags(&mut bags) |