Show More
@@ -0,0 +1,51 b'' | |||||
|
1 | // Copyright 2018 Yuya Nishihara <yuya@tcha.org> | |||
|
2 | // | |||
|
3 | // This software may be used and distributed according to the terms of the | |||
|
4 | // GNU General Public License version 2 or any later version. | |||
|
5 | ||||
|
6 | //! cHg extensions to command server client. | |||
|
7 | ||||
|
8 | use std::ffi::OsStr; | |||
|
9 | use std::os::unix::io::AsRawFd; | |||
|
10 | use tokio_hglib::{Client, Connection}; | |||
|
11 | ||||
|
12 | use super::attachio::AttachIo; | |||
|
13 | use super::message; | |||
|
14 | use super::runcommand::ChgRunCommand; | |||
|
15 | use super::uihandler::SystemHandler; | |||
|
16 | ||||
|
17 | pub trait ChgClientExt<C> | |||
|
18 | where C: Connection + AsRawFd, | |||
|
19 | { | |||
|
20 | /// Attaches the client file descriptors to the server. | |||
|
21 | fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E> | |||
|
22 | where I: AsRawFd, | |||
|
23 | O: AsRawFd, | |||
|
24 | E: AsRawFd; | |||
|
25 | ||||
|
26 | /// Runs the specified Mercurial command with cHg extension. | |||
|
27 | fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H> | |||
|
28 | where I: IntoIterator<Item = P>, | |||
|
29 | P: AsRef<OsStr>, | |||
|
30 | H: SystemHandler; | |||
|
31 | } | |||
|
32 | ||||
|
33 | impl<C> ChgClientExt<C> for Client<C> | |||
|
34 | where C: Connection + AsRawFd, | |||
|
35 | { | |||
|
36 | fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E> | |||
|
37 | where I: AsRawFd, | |||
|
38 | O: AsRawFd, | |||
|
39 | E: AsRawFd, | |||
|
40 | { | |||
|
41 | AttachIo::with_client(self, stdin, stdout, Some(stderr)) | |||
|
42 | } | |||
|
43 | ||||
|
44 | fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H> | |||
|
45 | where I: IntoIterator<Item = P>, | |||
|
46 | P: AsRef<OsStr>, | |||
|
47 | H: SystemHandler, | |||
|
48 | { | |||
|
49 | ChgRunCommand::with_client(self, handler, message::pack_args_os(args)) | |||
|
50 | } | |||
|
51 | } |
@@ -11,11 +11,13 b' extern crate tokio;' | |||||
11 | extern crate tokio_hglib; |
|
11 | extern crate tokio_hglib; | |
12 | extern crate tokio_process; |
|
12 | extern crate tokio_process; | |
13 |
|
13 | |||
14 |
|
|
14 | mod attachio; | |
|
15 | mod clientext; | |||
15 | pub mod locator; |
|
16 | pub mod locator; | |
16 | pub mod message; |
|
17 | pub mod message; | |
17 | pub mod procutil; |
|
18 | pub mod procutil; | |
18 |
|
|
19 | mod runcommand; | |
19 | mod uihandler; |
|
20 | mod uihandler; | |
20 |
|
21 | |||
|
22 | pub use clientext::ChgClientExt; | |||
21 | pub use uihandler::{ChgUiHandler, SystemHandler}; |
|
23 | pub use uihandler::{ChgUiHandler, SystemHandler}; |
General Comments 0
You need to be logged in to leave comments.
Login now