Created
February 21, 2018 22:21
-
-
Save opensourcegeek/396fe8d50111f528f7dfc0bac608f790 to your computer and use it in GitHub Desktop.
Failing code
This file contains hidden or 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() -> 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()); | |
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 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