Skip to content

Instantly share code, notes, and snippets.

@cnd
Created March 26, 2019 08:02
Show Gist options
  • Save cnd/fdcb891909fab26080af77f6da93bb29 to your computer and use it in GitHub Desktop.
Save cnd/fdcb891909fab26080af77f6da93bb29 to your computer and use it in GitHub Desktop.
pub struct SChannel<'s> {
pub channel: Channel<'s>,
}
impl<'i> ::std::ops::Deref for SChannel<'i> {
type Target = Channel<'i>;
fn deref(&self) -> &Channel<'i> { &self.channel }
}
pub struct Sess<'s> {
pub session: &'s Session,
pub channel: SChannel<'s>,
}
rental! {
pub mod rentals {
use super::*;
#[rental]
pub struct SSHSession {
session_box: Box<ssh2::Session>,
sess: Sess<'session_box>,
}
}
}
thread_local! {
pub static SSH_RENTAL: RefCell<Option<self::rentals::SSHSession>> = {
RefCell::new(None)
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment