diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/error.rs b/src/error.rs index 5eb92f9..d5dd397 100644 --- a/src/error.rs +++ b/src/error.rs @@ -15,14 +15,12 @@ pub struct Error { } impl Error { - /// Generate the last error that occurred for a `Session`. - /// - /// Returns `None` if there was no last error. - pub fn last_error(sess: &Session) -> Option<Error> { + #[doc(hidden)] + pub fn last_error_raw(raw: *mut raw::LIBSSH2_SESSION) -> Option<Error> { static STATIC: () = (); unsafe { let mut msg = 0 as *mut _; - let rc = raw::libssh2_session_last_error(sess.raw(), &mut msg, 0 as *mut _, 0); + let rc = raw::libssh2_session_last_error(raw, &mut msg, 0 as *mut _, 0); if rc == 0 { return None; } @@ -31,6 +29,13 @@ impl Error { } } + /// Generate the last error that occurred for a `Session`. + /// + /// Returns `None` if there was no last error. + pub fn last_error(sess: &Session) -> Option<Error> { + Self::last_error_raw(sess.raw()) + } + /// Create a new error for the given code and message pub fn new(code: libc::c_int, msg: &'static str) -> Error { Error { |