##// END OF EJS Templates
rust-cpython: add panicking version of borrow_mut() and use it...
rust-cpython: add panicking version of borrow_mut() and use it The original borrow_mut() is renamed to try_borrow_mut(). Since leak_immutable() no longer incref the borrow count, the caller should know if the underlying value is borrowed or not. No Python world is involved. That's why we can simply use the panicking borrow_mut().

File last commit:

r44270:ce088b38 default
r44685:2a24ead0 default
Show More
clientext.rs
72 lines | 2.0 KiB | application/rls-services+xml | RustLexer
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 // Copyright 2018 Yuya Nishihara <yuya@tcha.org>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
//! cHg extensions to command server client.
use std::ffi::OsStr;
Yuya Nishihara
rust-chg: add interface to chdir the server
r40014 use std::os::unix::ffi::OsStrExt;
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 use std::os::unix::io::AsRawFd;
Yuya Nishihara
rust-chg: add interface to chdir the server
r40014 use std::path::Path;
Gregory Szorc
rust: run rustfmt...
r44270 use tokio_hglib::protocol::OneShotRequest;
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 use tokio_hglib::{Client, Connection};
use super::attachio::AttachIo;
use super::message;
use super::runcommand::ChgRunCommand;
use super::uihandler::SystemHandler;
pub trait ChgClientExt<C>
Gregory Szorc
rust: run rustfmt...
r44270 where
C: Connection + AsRawFd,
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 {
/// Attaches the client file descriptors to the server.
fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E>
Gregory Szorc
rust: run rustfmt...
r44270 where
I: AsRawFd,
O: AsRawFd,
E: AsRawFd;
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013
Yuya Nishihara
rust-chg: add interface to chdir the server
r40014 /// Changes the working directory of the server.
fn set_current_dir<P>(self, dir: P) -> OneShotRequest<C>
Gregory Szorc
rust: run rustfmt...
r44270 where
P: AsRef<Path>;
Yuya Nishihara
rust-chg: add interface to chdir the server
r40014
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 /// Runs the specified Mercurial command with cHg extension.
fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
Gregory Szorc
rust: run rustfmt...
r44270 where
I: IntoIterator<Item = P>,
P: AsRef<OsStr>,
H: SystemHandler;
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 }
impl<C> ChgClientExt<C> for Client<C>
Gregory Szorc
rust: run rustfmt...
r44270 where
C: Connection + AsRawFd,
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 {
fn attach_io<I, O, E>(self, stdin: I, stdout: O, stderr: E) -> AttachIo<C, I, O, E>
Gregory Szorc
rust: run rustfmt...
r44270 where
I: AsRawFd,
O: AsRawFd,
E: AsRawFd,
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 {
AttachIo::with_client(self, stdin, stdout, Some(stderr))
}
Yuya Nishihara
rust-chg: add interface to chdir the server
r40014 fn set_current_dir<P>(self, dir: P) -> OneShotRequest<C>
Gregory Szorc
rust: run rustfmt...
r44270 where
P: AsRef<Path>,
Yuya Nishihara
rust-chg: add interface to chdir the server
r40014 {
OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes())
}
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 fn run_command_chg<I, P, H>(self, handler: H, args: I) -> ChgRunCommand<C, H>
Gregory Szorc
rust: run rustfmt...
r44270 where
I: IntoIterator<Item = P>,
P: AsRef<OsStr>,
H: SystemHandler,
Yuya Nishihara
rust-chg: add Client extensions to run cHg-specific requests...
r40013 {
ChgRunCommand::with_client(self, handler, message::pack_args_os(args))
}
}