summaryrefslogtreecommitdiff
path: root/src/channel.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-09-18 13:38:56 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-09-18 13:38:56 -0700
commit4ec939804b0a94e6396c311dfb11293e7cac3058 (patch)
treebb388573d3c061bc89d150dc922aa661b4e4b0a1 /src/channel.rs
parent2286cc8cf6c17cef456a89cc160a7400174761ce (diff)
downloadssh2-rs-4ec939804b0a94e6396c311dfb11293e7cac3058.zip
Add some basic channel tests
Diffstat (limited to 'src/channel.rs')
-rw-r--r--src/channel.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/channel.rs b/src/channel.rs
index bf1172c..f91adc6 100644
--- a/src/channel.rs
+++ b/src/channel.rs
@@ -56,7 +56,12 @@ impl<'a> Channel<'a> {
///
/// Typically sent after `close` in order to examine the exit status.
pub fn wait_close(&mut self) -> Result<(), Error> {
- unsafe { self.sess.rc(raw::libssh2_channel_wait_close(self.raw)) }
+ unsafe { self.sess.rc(raw::libssh2_channel_wait_closed(self.raw)) }
+ }
+
+ /// Wait for the remote end to acknowledge an EOF request.
+ pub fn wait_eof(&mut self) -> Result<(), Error> {
+ unsafe { self.sess.rc(raw::libssh2_channel_wait_eof(self.raw)) }
}
/// Check if the remote host has sent an EOF status for the selected stream.
@@ -125,7 +130,7 @@ impl<'a> Channel<'a> {
}
/// Get the remote exit signal.
- pub fn get_exit_signal(&self) -> Result<ExitSignal, Error> {
+ pub fn exit_signal(&self) -> Result<ExitSignal, Error> {
unsafe {
let mut sig = 0 as *mut _;
let mut siglen = 0;
@@ -160,12 +165,11 @@ impl<'a> Channel<'a> {
///
/// Note that the exit status may not be available if the remote end has not
/// yet set its status to closed.
- pub fn get_exit_status(&self) -> Result<int, Error> {
+ pub fn exit_status(&self) -> Result<int, Error> {
let ret = unsafe { raw::libssh2_channel_get_exit_status(self.raw) };
- if ret == 0 {
- Err(Error::last_error(self.sess).unwrap())
- } else {
- Ok(ret as int)
+ match Error::last_error(self.sess) {
+ Some(err) => Err(err),
+ None => Ok(ret as int)
}
}
}