diff --git a/eden/scm/lib/cpython-ext/src/path.rs b/eden/scm/lib/cpython-ext/src/path.rs index 10568481cc..8d95d9abf4 100644 --- a/eden/scm/lib/cpython-ext/src/path.rs +++ b/eden/scm/lib/cpython-ext/src/path.rs @@ -43,6 +43,18 @@ impl PyPath { pub fn to_repo_path<'a>(&'a self) -> Result<&'a RepoPath> { Ok(RepoPath::from_str(&self.0)?) } + + pub fn into_utf8_bytes(self) -> Vec { + self.0.into() + } + + pub fn as_utf8_bytes(&self) -> &[u8] { + self.0.as_bytes() + } + + pub fn from_utf8_bytes(utf8_bytes: Vec) -> Result { + Ok(Self(String::from_utf8(utf8_bytes)?)) + } } impl ToPyObject for PyPath { @@ -138,3 +150,9 @@ impl fmt::Display for PyPath { fmt::Display::fmt(&*self.0, formatter) } } + +impl From for String { + fn from(path: PyPath) -> String { + path.0 + } +}