Skip to content

Commit 60297bb

Browse files
committed
Attach::(run_command|run_shell) are callbacks)
1 parent 05d4970 commit 60297bb

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

src/attach.rs

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,28 @@ pub use lxc_sys::lxc_attach_exec_t as ExecFn;
44
/** LXC attach options for lxc::Container::attach(). */
55
pub use lxc_sys::lxc_attach_options_t as Options;
66

7-
bitflags::bitflags! {
8-
/** LXC environment policy. */
9-
pub struct EnvPolicy: i32 {
10-
/** Retain the environment */
11-
const KEEP_ENV = lxc_sys::lxc_attach_env_policy_t_LXC_ATTACH_KEEP_ENV as i32;
12-
/** Clear the environment */
13-
const CLEAR_ENV = lxc_sys::lxc_attach_env_policy_t_LXC_ATTACH_CLEAR_ENV as i32;
14-
}
15-
}
7+
/**
8+
* Run a shell command in the container.
9+
*
10+
* `payload` parameter is not used.
11+
*
12+
* Returns exit code of shell.
13+
*/
14+
pub use lxc_sys::lxc_attach_run_shell as run_shell;
1615

1716
/**
1817
* Run a command in the container.
1918
*
2019
* Returns exit code program on success.
2120
*/
22-
pub fn run_command(payload: &mut std::os::raw::c_void) -> Result<i32, ()> {
23-
let result = unsafe { lxc_sys::lxc_attach_run_command(payload) };
21+
pub use lxc_sys::lxc_attach_run_command as run_command;
2422

25-
if result == -1 {
26-
Err(())
27-
} else {
28-
Ok(result)
23+
bitflags::bitflags! {
24+
/** LXC environment policy. */
25+
pub struct EnvPolicy: i32 {
26+
/** Retain the environment */
27+
const KEEP_ENV = lxc_sys::lxc_attach_env_policy_t_LXC_ATTACH_KEEP_ENV as i32;
28+
/** Clear the environment */
29+
const CLEAR_ENV = lxc_sys::lxc_attach_env_policy_t_LXC_ATTACH_CLEAR_ENV as i32;
2930
}
3031
}
31-
32-
/**
33-
* Run a shell command in the container.
34-
*
35-
* `_payload` parameter is not used.
36-
*
37-
* Returns exit code of shell.
38-
*/
39-
pub fn run_shell(_payload: &mut std::os::raw::c_void) -> i32 {
40-
unsafe { lxc_sys::lxc_attach_run_shell(_payload) }
41-
}

0 commit comments

Comments
 (0)