Update Ssh2AuthHandler to take a lifetime

pull/59/head
Chip Senkbeil 3 years ago
parent 5d28b69596
commit 43ffd7ae58
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

6
Cargo.lock generated

@ -429,7 +429,7 @@ dependencies = [
[[package]]
name = "distant"
version = "0.15.0-alpha.4"
version = "0.15.0-alpha.5"
dependencies = [
"assert_cmd",
"assert_fs",
@ -453,7 +453,7 @@ dependencies = [
[[package]]
name = "distant-core"
version = "0.15.0-alpha.4"
version = "0.15.0-alpha.5"
dependencies = [
"assert_fs",
"bytes",
@ -478,7 +478,7 @@ dependencies = [
[[package]]
name = "distant-ssh2"
version = "0.15.0-alpha.4"
version = "0.15.0-alpha.5"
dependencies = [
"assert_cmd",
"assert_fs",

@ -74,14 +74,14 @@ pub struct Ssh2SessionOpts {
pub other: BTreeMap<String, String>,
}
pub struct Ssh2AuthHandler {
pub on_authenticate: Box<dyn FnMut(Ssh2AuthEvent) -> io::Result<Vec<String>>>,
pub on_banner: Box<dyn FnMut(&str)>,
pub on_host_verify: Box<dyn FnMut(&str) -> io::Result<bool>>,
pub on_error: Box<dyn FnMut(&str)>,
pub struct Ssh2AuthHandler<'a> {
pub on_authenticate: Box<dyn FnMut(Ssh2AuthEvent) -> io::Result<Vec<String>> + 'a>,
pub on_banner: Box<dyn FnMut(&str) + 'a>,
pub on_host_verify: Box<dyn FnMut(&str) -> io::Result<bool> + 'a>,
pub on_error: Box<dyn FnMut(&str) + 'a>,
}
impl Default for Ssh2AuthHandler {
impl Default for Ssh2AuthHandler<'static> {
fn default() -> Self {
Self {
on_authenticate: Box::new(|ev| {
@ -200,7 +200,7 @@ impl Ssh2Session {
}
/// Authenticates the [`Ssh2Session`] and produces a [`Session`]
pub async fn authenticate(self, mut handler: Ssh2AuthHandler) -> io::Result<Session> {
pub async fn authenticate(self, mut handler: Ssh2AuthHandler<'_>) -> io::Result<Session> {
// Perform the authentication by listening for events and continuing to handle them
// until authenticated
while let Ok(event) = self.events.recv().await {

Loading…
Cancel
Save