diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-01-17 15:23:18 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-17 15:23:18 -0800 |
commit | e2b22f1665ecfb776e17ced93473cf5695ed00d4 (patch) | |
tree | d43a5b3dca2f6adc8507ad79a33df8c4a215f8a9 /src | |
parent | ea6e306c68450a88024bbc615361144297703ed0 (diff) | |
download | ssh2-rs-e2b22f1665ecfb776e17ced93473cf5695ed00d4.zip |
Update to rust master
Diffstat (limited to 'src')
-rw-r--r-- | src/agent.rs | 12 | ||||
-rw-r--r-- | src/channel.rs | 15 | ||||
-rw-r--r-- | src/knownhosts.rs | 12 | ||||
-rw-r--r-- | src/listener.rs | 14 | ||||
-rw-r--r-- | src/session.rs | 5 | ||||
-rw-r--r-- | src/sftp.rs | 34 |
6 files changed, 32 insertions, 60 deletions
diff --git a/src/agent.rs b/src/agent.rs index a5a0eb1..f7fa943 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -11,7 +11,6 @@ use {raw, Session, Error}; pub struct Agent<'sess> { raw: *mut raw::LIBSSH2_AGENT, sess: &'sess Session, - marker: marker::NoSync, } /// An iterator over the identities found in an SSH agent. @@ -23,10 +22,7 @@ pub struct Identities<'agent> { /// A public key which is extracted from an SSH agent. pub struct PublicKey<'agent> { raw: *mut raw::libssh2_agent_publickey, - marker1: marker::NoSync, - marker2: marker::NoSend, - marker3: marker::ContravariantLifetime<'agent>, - marker4: marker::NoCopy, + marker: marker::ContravariantLifetime<'agent>, } impl<'sess> Agent<'sess> { @@ -39,7 +35,6 @@ impl<'sess> Agent<'sess> { Agent { raw: raw, sess: sess, - marker: marker::NoSync, } } @@ -111,10 +106,7 @@ impl<'agent> PublicKey<'agent> { -> PublicKey<'agent> { PublicKey { raw: raw, - marker1: marker::NoSync, - marker2: marker::NoSend, - marker3: marker::ContravariantLifetime, - marker4: marker::NoCopy, + marker: marker::ContravariantLifetime, } } diff --git a/src/channel.rs b/src/channel.rs index b111e4a..7db0719 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -1,6 +1,5 @@ use std::cmp; use std::io; -use std::marker; use libc::{c_uint, c_int, size_t, c_char, c_void, c_uchar}; use {raw, Session, Error}; @@ -10,10 +9,9 @@ use {raw, Session, Error}; /// /// Channels denote all of SCP uploads and downloads, shell sessions, remote /// process executions, and other general-purpose sessions. -pub struct Channel<'a> { +pub struct Channel<'sess> { raw: *mut raw::LIBSSH2_CHANNEL, - sess: &'a Session, - marker: marker::NoSync, + sess: &'sess Session, read_limit: Option<u64>, } @@ -50,7 +48,7 @@ pub struct WriteWindow { pub window_size_initial: u32, } -impl<'a> Channel<'a> { +impl<'sess> Channel<'sess> { /// Wraps a raw pointer in a new Channel structure tied to the lifetime of the /// given session. /// @@ -60,7 +58,6 @@ impl<'a> Channel<'a> { Channel { raw: raw, sess: sess, - marker: marker::NoSync, read_limit: None, } } @@ -387,7 +384,7 @@ impl<'a> Channel<'a> { } } -impl<'a> Writer for Channel<'a> { +impl<'sess> Writer for Channel<'sess> { fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { self.write_stream(0, buf).map_err(|e| { io::IoError { @@ -409,7 +406,7 @@ impl<'a> Writer for Channel<'a> { } } -impl<'a> Reader for Channel<'a> { +impl<'sess> Reader for Channel<'sess> { fn read(&mut self, buf: &mut [u8]) -> io::IoResult<usize> { self.read_stream(0, buf).map_err(|e| { if self.eof() { @@ -426,7 +423,7 @@ impl<'a> Reader for Channel<'a> { } #[unsafe_destructor] -impl<'a> Drop for Channel<'a> { +impl<'sess> Drop for Channel<'sess> { fn drop(&mut self) { unsafe { assert_eq!(raw::libssh2_channel_free(self.raw), 0) } } diff --git a/src/knownhosts.rs b/src/knownhosts.rs index 1e1e98c..da8a697 100644 --- a/src/knownhosts.rs +++ b/src/knownhosts.rs @@ -48,7 +48,6 @@ use {raw, Session, Error, KnownHostFileKind, CheckResult}; pub struct KnownHosts<'sess> { raw: *mut raw::LIBSSH2_KNOWNHOSTS, sess: &'sess Session, - marker: marker::NoSync, } /// Iterator over the hosts in a `KnownHosts` structure. @@ -60,9 +59,7 @@ pub struct Hosts<'kh> { /// Structure representing a known host as part of a `KnownHosts` structure. pub struct Host<'kh> { raw: *mut raw::libssh2_knownhost, - marker1: marker::NoSync, - marker2: marker::NoSend, - marker3: marker::ContravariantLifetime<'kh>, + marker: marker::ContravariantLifetime<'kh>, } impl<'sess> KnownHosts<'sess> { @@ -75,7 +72,6 @@ impl<'sess> KnownHosts<'sess> { KnownHosts { raw: raw, sess: sess, - marker: marker::NoSync, } } @@ -222,7 +218,7 @@ impl<'sess> KnownHosts<'sess> { } #[unsafe_destructor] -impl<'a> Drop for KnownHosts<'a> { +impl<'sess> Drop for KnownHosts<'sess> { fn drop(&mut self) { unsafe { raw::libssh2_knownhost_free(self.raw) } } @@ -253,9 +249,7 @@ impl<'kh> Host<'kh> { -> Host<'kh> { Host { raw: raw, - marker1: marker::NoSync, - marker2: marker::NoSend, - marker3: marker::ContravariantLifetime, + marker: marker::ContravariantLifetime, } } diff --git a/src/listener.rs b/src/listener.rs index ab88abe..6ea3ad8 100644 --- a/src/listener.rs +++ b/src/listener.rs @@ -1,18 +1,15 @@ -use std::marker; - use {raw, Session, Error, Channel}; /// A listener represents a forwarding port from the remote server. /// /// New channels can be accepted from a listener which represent connections on /// the remote server's port. -pub struct Listener<'a> { +pub struct Listener<'sess> { raw: *mut raw::LIBSSH2_LISTENER, - sess: &'a Session, - marker: marker::NoSync, + sess: &'sess Session, } -impl<'a> Listener<'a> { +impl<'sess> Listener<'sess> { /// Wraps a raw pointer in a new Listener structure tied to the lifetime of the /// given session. /// @@ -22,12 +19,11 @@ impl<'a> Listener<'a> { Listener { raw: raw, sess: sess, - marker: marker::NoSync, } } /// Accept a queued connection from this listener. - pub fn accept(&mut self) -> Result<Channel<'a>, Error> { + pub fn accept(&mut self) -> Result<Channel<'sess>, Error> { unsafe { let ret = raw::libssh2_channel_forward_accept(self.raw); if ret.is_null() { @@ -40,7 +36,7 @@ impl<'a> Listener<'a> { } #[unsafe_destructor] -impl<'a> Drop for Listener<'a> { +impl<'sess> Drop for Listener<'sess> { fn drop(&mut self) { unsafe { assert_eq!(raw::libssh2_channel_forward_cancel(self.raw), 0) } } diff --git a/src/session.rs b/src/session.rs index a98e63a..3ee43f5 100644 --- a/src/session.rs +++ b/src/session.rs @@ -1,6 +1,5 @@ use std::ffi::CString; use std::io; -use std::marker; use std::mem; use std::slice; use std::str; @@ -16,9 +15,10 @@ use {MethodType, Agent, Channel, Listener, HashType, KnownHosts, Sftp}; /// (via the `handshake` method). pub struct Session { raw: *mut raw::LIBSSH2_SESSION, - marker: marker::NoSync, } +unsafe impl Send for Session {} + impl Session { /// Initializes an SSH session object. pub fn new() -> Option<Session> { @@ -36,7 +36,6 @@ impl Session { pub unsafe fn from_raw(raw: *mut raw::LIBSSH2_SESSION) -> Session { Session { raw: raw, - marker: marker::NoSync, } } diff --git a/src/sftp.rs b/src/sftp.rs index 07380ef..3aa2260 100644 --- a/src/sftp.rs +++ b/src/sftp.rs @@ -8,11 +8,9 @@ use {raw, Session, Error}; /// A handle to a remote filesystem over SFTP. /// /// Instances are created through the `sftp` method on a `Session`. -pub struct Sftp<'a> { +pub struct Sftp<'sess> { raw: *mut raw::LIBSSH2_SFTP, - marker1: marker::NoSync, - marker2: marker::ContravariantLifetime<'a>, - marker3: marker::NoSend, + marker: marker::ContravariantLifetime<'sess>, } /// A file handle to an SFTP connection. @@ -22,10 +20,9 @@ pub struct Sftp<'a> { /// /// Files are created through `open`, `create`, and `open_mode` on an instance /// of `Sftp`. -pub struct File<'a> { +pub struct File<'sftp> { raw: *mut raw::LIBSSH2_SFTP_HANDLE, - sftp: &'a Sftp<'a>, - marker: marker::NoSync, + sftp: &'sftp Sftp<'sftp>, } /// Metadata information about a remote file. @@ -97,7 +94,7 @@ pub enum OpenType { Dir = raw::LIBSSH2_SFTP_OPENDIR as isize, } -impl<'a> Sftp<'a> { +impl<'sess> Sftp<'sess> { /// Wraps a raw pointer in a new Sftp structure tied to the lifetime of the /// given session. /// @@ -106,9 +103,7 @@ impl<'a> Sftp<'a> { raw: *mut raw::LIBSSH2_SFTP) -> Sftp { Sftp { raw: raw, - marker1: marker::NoSync, - marker2: marker::ContravariantLifetime, - marker3: marker::NoSend, + marker: marker::ContravariantLifetime, } } @@ -327,23 +322,22 @@ impl<'a> Sftp<'a> { } #[unsafe_destructor] -impl<'a> Drop for Sftp<'a> { +impl<'sess> Drop for Sftp<'sess> { fn drop(&mut self) { unsafe { assert_eq!(raw::libssh2_sftp_shutdown(self.raw), 0) } } } -impl<'a> File<'a> { +impl<'sftp> File<'sftp> { /// Wraps a raw pointer in a new File structure tied to the lifetime of the /// given session. /// /// This consumes ownership of `raw`. - pub unsafe fn from_raw(sftp: &'a Sftp<'a>, - raw: *mut raw::LIBSSH2_SFTP_HANDLE) -> File<'a> { + pub unsafe fn from_raw(sftp: &'sftp Sftp<'sftp>, + raw: *mut raw::LIBSSH2_SFTP_HANDLE) -> File<'sftp> { File { raw: raw, sftp: sftp, - marker: marker::NoSync, } } @@ -421,7 +415,7 @@ impl<'a> File<'a> { } } -impl<'a> Reader for File<'a> { +impl<'sftp> Reader for File<'sftp> { fn read(&mut self, buf: &mut [u8]) -> io::IoResult<usize> { unsafe { let rc = raw::libssh2_sftp_read(self.raw, @@ -440,7 +434,7 @@ impl<'a> Reader for File<'a> { } } -impl<'a> Writer for File<'a> { +impl<'sftp> Writer for File<'sftp> { fn write(&mut self, mut buf: &[u8]) -> io::IoResult<()> { while buf.len() > 0 { let rc = unsafe { @@ -461,7 +455,7 @@ impl<'a> Writer for File<'a> { } } -impl<'a> Seek for File<'a> { +impl<'sftp> Seek for File<'sftp> { fn tell(&self) -> io::IoResult<u64> { Ok(unsafe { raw::libssh2_sftp_tell64(self.raw) }) } @@ -502,7 +496,7 @@ impl<'a> Seek for File<'a> { } #[unsafe_destructor] -impl<'a> Drop for File<'a> { +impl<'sftp> Drop for File<'sftp> { fn drop(&mut self) { unsafe { assert_eq!(raw::libssh2_sftp_close_handle(self.raw), 0) } } |