-
-
Save mbrubeck/60e794d5f6437a49c25fcd2fa276aee0 to your computer and use it in GitHub Desktop.
Failing code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate ssh2; | |
use std::net::TcpStream; | |
use ssh2::Session; | |
fn create_session() -> (TcpStream, Session) { | |
let tcp = TcpStream::connect("test:22").expect("Cannot connect"); | |
let mut sess = Session::new().expect("cannot start session"); | |
sess.handshake(&tcp).expect("handshake failed"); | |
sess.userauth_password("test", "boo").expect("Cannot authenticate"); | |
assert!(sess.authenticated()); | |
(tcp, sess) | |
} | |
struct Sample<'a> { | |
// session: Session, | |
sftp: ssh2::Sftp<'a> | |
} | |
impl <'a> Sample<'a> { | |
fn new(sftp: ssh2::Sftp<'a>) -> Sample<'a> { | |
Sample { | |
// session: s, | |
sftp | |
} | |
} | |
fn print_some(&self) -> () { | |
println!("Got it!!"); | |
} | |
} | |
fn main() { | |
let (_stream, sess) = create_session(); | |
let sftp = sess.sftp(); | |
match sftp { | |
Ok(sftp) => { | |
let s = Sample::new(sftp); | |
s.print_some(); | |
}, | |
Err(e) => { | |
println!("Cannot start sftp {:?}", e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment