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.

47 lines
863 B

  1. use std::path::{Path as ActualPath, PathBuf};
  2. #[derive(Clone, Debug)]
  3. pub struct Path(PathBuf);
  4. // FIXME: This is a specialization since with Path: Into<PathBuf>
  5. // it would overwrite impl<T> From <T> for T
  6. //impl<T: Into<PathBuf>> From<T> for Path {
  7. // fn from(v: T) -> Self {
  8. // Path(v.into())
  9. // }
  10. //}
  11. macro_rules! path_from {
  12. ( $t:ty ) => {
  13. impl From<$t> for Path {
  14. fn from(v: $t) -> Self {
  15. Self(v.into())
  16. }
  17. }
  18. };
  19. }
  20. path_from!(String);
  21. path_from!(&str);
  22. path_from!(PathBuf);
  23. impl From<Path> for PathBuf {
  24. fn from(v: Path) -> Self {
  25. v.0
  26. }
  27. }
  28. impl AsRef<ActualPath> for Path {
  29. fn as_ref(&self) -> &ActualPath {
  30. &self.0
  31. }
  32. }
  33. #[derive(Clone, Debug)]
  34. pub struct UserName(pub String);
  35. #[derive(Clone, Debug)]
  36. pub struct ServiceName(pub String);
  37. #[derive(Clone, Debug)]
  38. pub struct DatabaseName(pub String);