heim_process/process/
command.rs1use std::ffi::{OsStr, OsString};
2use std::fmt;
3
4use crate::sys;
5use heim_common::prelude::wrap;
6
7pub struct Command(sys::Command);
9
10wrap!(Command, sys::Command);
11
12impl Command {
13 pub fn to_os_string(&self) -> OsString {
21 self.as_ref().to_os_string()
22 }
23
24 pub fn into_os_string(self) -> OsString {
32 self.0.into_os_string()
33 }
34}
35
36impl fmt::Debug for Command {
37 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
38 f.debug_tuple("Command")
39 .field(&self.to_os_string())
40 .finish()
41 }
42}
43
44#[derive(Debug)]
46pub struct CommandIter<'a>(sys::CommandIter<'a>);
47
48wrap!('a, CommandIter<'a>, sys::CommandIter<'a>);
49
50impl<'a> IntoIterator for &'a Command {
51 type Item = &'a OsStr;
52 type IntoIter = CommandIter<'a>;
53
54 fn into_iter(self) -> Self::IntoIter {
55 self.0.into_iter().into()
56 }
57}
58
59impl<'a> Iterator for CommandIter<'a> {
60 type Item = &'a OsStr;
61
62 fn next(&mut self) -> Option<Self::Item> {
63 self.0.next()
64 }
65}