1use core_policy::Resource;
2
3pub fn parse_resource(resource: &str) -> Resource {
5 if resource == "*" {
6 return Resource::All;
7 }
8
9 if let Some(stripped) = resource.strip_prefix("file:") {
10 return Resource::File(stripped.to_string());
11 }
12
13 if let Some(stripped) = resource.strip_prefix("usb:") {
14 return Resource::Usb(stripped.to_string());
15 }
16
17 if let Some(stripped) = resource.strip_prefix("tunnel:") {
18 return Resource::Tunnel(stripped.to_string());
19 }
20
21 if let Some((resource_type, path)) = resource.split_once(':') {
23 Resource::Custom {
24 resource_type: resource_type.to_string(),
25 path: path.to_string(),
26 }
27 } else {
28 Resource::File(resource.to_string())
30 }
31}