pub struct Server { /* private fields */ }Expand description
一个服务器,侦听传入的 Unix 域套接字 (UDS) 连接并处理命令。
Implementations§
Source§impl Server
impl Server
Sourcepub fn new(
shell_: Shell,
uds_cmd_path_: String,
uds_output_path_: String,
) -> Server
pub fn new( shell_: Shell, uds_cmd_path_: String, uds_output_path_: String, ) -> Server
创建一个新的 Server 实例。
§Arguments
shell_- 要在服务器上执行的 shell 实例。uds_cmd_path_- Unix 域套接字 (UDS) 路径,用于侦听命令。uds_output_path_- Unix 域套接字 (UDS) 路径,用于侦听输出。
§Returns
一个新的 Server 实例。
Examples found in repository?
examples/main.rs (lines 51-55)
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 run(&mut self) -> Result<(), String>
pub fn run(&mut self) -> Result<(), String>
Examples found in repository?
examples/main.rs (line 56)
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}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe for Server
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