Last active
September 8, 2019 01:51
-
-
Save andoriyu/6bc29062a3dcce3429774b2892bcde74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn list_filesystems<N: Into<PathBuf>>(&self, pool: N) -> Result<impl Iterator<Item = PathBuf> { | |
let mut z = self.zfs_mute(); | |
z.args(&["list", "-t", "filesystem", "-o", "name", "-Hpr"]); | |
z.arg(pool.into().as_os_str()); | |
debug!(self.logger, "executing"; "cmd" => format_args!("{:?}", z)); | |
let out = z.output()?; | |
if out.status.success() { | |
let stdout = String::from_utf8_lossy(&out.stdout); | |
ZfsParser::parse(Rule::datasets, &stdout) | |
.map(|mut pairs| { | |
pairs.next().unwrap().into_inner() | |
.map(|pair| { | |
debug_assert_eq!(Rule::dataset_name, pair.as_rule()); | |
PathBuf::from(pair.as_str()) | |
}) | |
}) | |
.map_err(|_| Error::UnknownSoFar(String::from(stdout))) | |
} else { | |
Err(Error::from_stderr(&out.stderr)) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn list_filesystems<N: Into<PathBuf>>(&self, pool: N) -> Result<Vec<PathBuf>> { | |
let mut z = self.zfs_mute(); | |
z.args(&["list", "-t", "filesystem", "-o", "name", "-Hpr"]); | |
z.arg(pool.into().as_os_str()); | |
debug!(self.logger, "executing"; "cmd" => format_args!("{:?}", z)); | |
let out = z.output()?; | |
if out.status.success() { | |
let stdout = String::from_utf8_lossy(&out.stdout); | |
ZfsParser::parse(Rule::datasets, &stdout) | |
.map(|mut pairs| { | |
pairs.next().unwrap().into_inner() | |
.map(|pair| { | |
debug_assert_eq!(Rule::dataset_name, pair.as_rule()); | |
PathBuf::from(pair.as_str()) | |
}) | |
.collect() | |
}) | |
.map_err(|_| Error::UnknownSoFar(String::from(stdout))) | |
} else { | |
Err(Error::from_stderr(&out.stderr)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment