pub struct Shell { /* private fields */ }Implementations§
Source§impl Shell
impl Shell
Sourcepub fn new() -> Shell
pub fn new() -> Shell
创建一个新的 Shell 实例。
§示例
use std::collections::HashMap;
use shell_server::{Shell};
fn main() {
let shell = Shell::new();
// 接下来可以添加函数并使用 shell 进行操作
}Examples found in repository?
examples/main.rs (line 37)
36fn main() {
37 let mut shell = Shell::new();
38
39 reg_shell_cmd!(shell,
40 {"hello", print_hello},
41 {"add_two", add_two},
42 {"print_str", print_str},
43 {"add_seven", add_seven},
44 {"run_exit", exit}
45 );
46
47 let pid = get_self_pid();
48
49 println!("pid: {}", pid);
50
51 match Server::new(
52 shell,
53 format!("/tmp/rust_shell_cmd_{}", pid),
54 format!("/tmp/rust_shell_output_{}", pid),
55 )
56 .run()
57 {
58 Ok(_) => (),
59 Err(err) => println!("run err: {}", err),
60 }
61}Sourcepub fn get_reg_commands(&self) -> Vec<String>
pub fn get_reg_commands(&self) -> Vec<String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shell
impl RefUnwindSafe for Shell
impl Send for Shell
impl Sync for Shell
impl Unpin for Shell
impl UnwindSafe for Shell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more