A library for writing host-specific, single-binary configuration management and deployment tools
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
661 B

7 years ago
  1. use std::borrow::Cow;
  2. pub trait Resource {
  3. fn get_type(&self) -> &str;
  4. fn get_value(&self) -> &str;
  5. }
  6. pub struct UserResource<'a> {
  7. pub name: &'a str
  8. }
  9. impl<'a> Resource for UserResource<'a> {
  10. fn get_type(&self) -> &str { "user" }
  11. fn get_value(&self) -> &str { self.name }
  12. }
  13. pub struct DirResource<'a> {
  14. pub path: Cow<'a, str>
  15. }
  16. impl<'a> Resource for DirResource<'a> {
  17. fn get_type(&self) -> &str { "dir" }
  18. fn get_value(&self) -> &str { &*self.path }
  19. }
  20. pub struct FileResource<'a> {
  21. pub path: Cow<'a, str>
  22. }
  23. impl<'a> Resource for FileResource<'a> {
  24. fn get_type(&self) -> &str { "file" }
  25. fn get_value(&self) -> &str { &*self.path }
  26. }