summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@wezfurlong.org>2019-07-23 16:34:16 -0700
committerWez Furlong <wez@wezfurlong.org>2019-07-29 08:55:06 -0700
commit19c95e8c79723e22a35de302cb8f768f9d133dbc (patch)
tree70aeab07baf122c04a0c7127967cad2ff1e79e8a
parent18dc0f59e0b29c50da525dbe85d36fb5cb0ecf62 (diff)
downloadssh2-rs-19c95e8c79723e22a35de302cb8f768f9d133dbc.zip
Session::new() now returns Result rather than Option
Refs: https://github.com/alexcrichton/ssh2-rs/issues/96 This is a breaking change, so bump the package version
-rw-r--r--Cargo.toml2
-rw-r--r--src/session.rs6
2 files changed, 4 insertions, 4 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8745af2..5f93fcc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ssh2"
-version = "0.3.3"
+version = "0.4.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0"
keywords = ["ssh"]
diff --git a/src/session.rs b/src/session.rs
index 71af745..10a0703 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -36,14 +36,14 @@ impl Session {
/// mode, compression, sigpipe, the banner, etc. To associate this session
/// with a TCP connection, use the `handshake` method to pass in an
/// already-established TCP socket.
- pub fn new() -> Option<Session> {
+ pub fn new() -> Result<Session, Error> {
::init();
unsafe {
let ret = raw::libssh2_session_init_ex(None, None, None, 0 as *mut _);
if ret.is_null() {
- None
+ Err(Error::unknown())
} else {
- Some(Binding::from_raw(ret))
+ Ok(Binding::from_raw(ret))
}
}
}