Mercurial > public > mercurial-scm > hg-stable
annotate rust/chg/src/clientext.rs @ 45623:426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
`hg fix` runs the formatters from the repo root so it doesn't pick up
the `rustfmt.toml` configs we had in each the `hg-core`, `hg-cpython`,
and `rhg` packages, which resulted in warnings about `async fn` not
existing in Rust 2015. This patch moves the `rustfmt.toml` file to the
root so `hg fix` will use it.
By putting the `rustfmt.toml` file in a higher-level directory, it
also applies to the `chg` and `hgcli` packages. That makes
`test-check-rust-format.t` fail, so this patch also applies the new
formatting rules to those packages.
Differential Revision: https://phab.mercurial-scm.org/D9142
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 01 Oct 2020 09:09:35 -0700 |
parents | d6f706929120 |
children |
rev | line source |
---|---|
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
1 // Copyright 2018 Yuya Nishihara <yuya@tcha.org> |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
2 // |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
3 // This software may be used and distributed according to the terms of the |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
4 // GNU General Public License version 2 or any later version. |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
5 |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
6 //! cHg extensions to command server client. |
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
7 |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
8 use bytes::{BufMut, BytesMut}; |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
9 use std::ffi::OsStr; |
44681
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
10 use std::io; |
44684
065048e66f32
rust-chg: send client side umask to server
Yuya Nishihara <yuya@tcha.org>
parents:
44681
diff
changeset
|
11 use std::mem; |
39979
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39978
diff
changeset
|
12 use std::os::unix::ffi::OsStrExt; |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
13 use std::os::unix::io::AsRawFd; |
39979
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39978
diff
changeset
|
14 use std::path::Path; |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
15 use tokio_hglib::UnixClient; |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
16 |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
17 use crate::attachio; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
18 use crate::message::{self, Instruction, ServerSpec}; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
19 use crate::runcommand; |
44690
6bef9d43cc55
rust-chg: use "crate::" to import local modules
Yuya Nishihara <yuya@tcha.org>
parents:
44685
diff
changeset
|
20 use crate::uihandler::SystemHandler; |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
21 |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
22 /// Command-server client that also supports cHg extensions. |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
23 pub struct ChgClient { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
24 client: UnixClient, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
25 } |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
26 |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
27 impl ChgClient { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
28 /// Connects to a command server listening at the specified socket path. |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
29 pub async fn connect(path: impl AsRef<Path>) -> io::Result<Self> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
30 let client = UnixClient::connect(path).await?; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
31 Ok(ChgClient { client }) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
32 } |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
33 |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
34 /// Server capabilities, encoding, etc. |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
35 pub fn server_spec(&self) -> &ServerSpec { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
36 self.client.server_spec() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
37 } |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
38 |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
39 /// Attaches the client file descriptors to the server. |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
40 pub async fn attach_io( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
41 &mut self, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
42 stdin: &impl AsRawFd, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
43 stdout: &impl AsRawFd, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
44 stderr: &impl AsRawFd, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
45 ) -> io::Result<()> { |
45623
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
46 attachio::attach_io( |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
47 self.client.borrow_protocol_mut(), |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
48 stdin, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
49 stdout, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
50 stderr, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
51 ) |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
52 .await |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
53 } |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
54 |
39979
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39978
diff
changeset
|
55 /// Changes the working directory of the server. |
45623
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
56 pub async fn set_current_dir( |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
57 &mut self, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
58 dir: impl AsRef<Path>, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
59 ) -> io::Result<()> { |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
60 let dir_bytes = dir.as_ref().as_os_str().as_bytes().to_owned(); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
61 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
62 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
63 .send_command_with_args("chdir", dir_bytes) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
64 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
65 } |
39979
045ea159418d
rust-chg: add interface to chdir the server
Yuya Nishihara <yuya@tcha.org>
parents:
39978
diff
changeset
|
66 |
44676
97e6d435ff7e
rust-chg: send client-side environment variables to server
Yuya Nishihara <yuya@tcha.org>
parents:
43836
diff
changeset
|
67 /// Updates the environment variables of the server. |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
68 pub async fn set_env_vars_os( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
69 &mut self, |
44693
61fda2dbc522
rust-chg: leverage impl trait at argument position
Yuya Nishihara <yuya@tcha.org>
parents:
44690
diff
changeset
|
70 vars: impl IntoIterator<Item = (impl AsRef<OsStr>, impl AsRef<OsStr>)>, |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
71 ) -> io::Result<()> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
72 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
73 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
74 .send_command_with_args("setenv", message::pack_env_vars_os(vars)) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
75 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
76 } |
44676
97e6d435ff7e
rust-chg: send client-side environment variables to server
Yuya Nishihara <yuya@tcha.org>
parents:
43836
diff
changeset
|
77 |
44685
80d6e3415636
rust-chg: update name of the server process
Yuya Nishihara <yuya@tcha.org>
parents:
44684
diff
changeset
|
78 /// Changes the process title of the server. |
45623
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
79 pub async fn set_process_name( |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
80 &mut self, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
81 name: impl AsRef<OsStr>, |
426294d06ddc
rust: move rustfmt.toml to repo root so it can be used by `hg fix`
Martin von Zweigbergk <martinvonz@google.com>
parents:
44852
diff
changeset
|
82 ) -> io::Result<()> { |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
83 let name_bytes = name.as_ref().as_bytes().to_owned(); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
84 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
85 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
86 .send_command_with_args("setprocname", name_bytes) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
87 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
88 } |
44685
80d6e3415636
rust-chg: update name of the server process
Yuya Nishihara <yuya@tcha.org>
parents:
44684
diff
changeset
|
89 |
44684
065048e66f32
rust-chg: send client side umask to server
Yuya Nishihara <yuya@tcha.org>
parents:
44681
diff
changeset
|
90 /// Changes the umask of the server process. |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
91 pub async fn set_umask(&mut self, mask: u32) -> io::Result<()> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
92 let mut mask_bytes = BytesMut::with_capacity(mem::size_of_val(&mask)); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
93 mask_bytes.put_u32(mask); |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
94 self.client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
95 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
96 .send_command_with_args("setumask2", mask_bytes) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
97 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
98 } |
44684
065048e66f32
rust-chg: send client side umask to server
Yuya Nishihara <yuya@tcha.org>
parents:
44681
diff
changeset
|
99 |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
100 /// Runs the specified Mercurial command with cHg extension. |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
101 pub async fn run_command_chg( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
102 &mut self, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
103 handler: &mut impl SystemHandler, |
44693
61fda2dbc522
rust-chg: leverage impl trait at argument position
Yuya Nishihara <yuya@tcha.org>
parents:
44690
diff
changeset
|
104 args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
105 ) -> io::Result<i32> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
106 runcommand::run_command( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
107 self.client.borrow_protocol_mut(), |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
108 handler, |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
109 message::pack_args_os(args), |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
110 ) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
111 .await |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
112 } |
44681
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
113 |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
114 /// Validates if the server can run Mercurial commands with the expected |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
115 /// configuration. |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
116 /// |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
117 /// The `args` should contain early command arguments such as `--config` |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
118 /// and `-R`. |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
119 /// |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
120 /// Client-side environment must be sent prior to this request, by |
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
121 /// `set_current_dir()` and `set_env_vars_os()`. |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
122 pub async fn validate( |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
123 &mut self, |
44693
61fda2dbc522
rust-chg: leverage impl trait at argument position
Yuya Nishihara <yuya@tcha.org>
parents:
44690
diff
changeset
|
124 args: impl IntoIterator<Item = impl AsRef<OsStr>>, |
44852
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
125 ) -> io::Result<Vec<Instruction>> { |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
126 let data = self |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
127 .client |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
128 .borrow_protocol_mut() |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
129 .query_with_args("validate", message::pack_args_os(args)) |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
130 .await?; |
d6f706929120
rust-chg: reimplement ChgClientExt as ChgClient wrapper
Yuya Nishihara <yuya@tcha.org>
parents:
44847
diff
changeset
|
131 message::parse_instructions(data) |
44681
43513444bb88
rust-chg: add interface to run "validate" request
Yuya Nishihara <yuya@tcha.org>
parents:
44676
diff
changeset
|
132 } |
39978
74da9d999cd7
rust-chg: add Client extensions to run cHg-specific requests
Yuya Nishihara <yuya@tcha.org>
parents:
diff
changeset
|
133 } |