/// Asks for a passphrase or PIN.
Asks for a passphrase or PIN.
Asks for a passphrase or PIN .
pub fn interact(&self) -> Result<SecretString> {
        let mut pinentry = assuan::Connection::open(&self.binary)?;
        if let Some(title) = &self.title {
            pinentry.send_request("SETTITLE", Some(title))?;
        }
        if let Some(desc) = &self.description {
            pinentry.send_request("SETDESC", Some(desc))?;
        }
        if let Some(error) = &self.error {
            pinentry.send_request("SETERROR", Some(error))?;
        }
        if let Some(prompt) = &self.prompt {
            pinentry.send_request("SETPROMPT", Some(prompt))?;
        }
        if let Some(ok) = &self.ok {
            pinentry.send_request("SETOK", Some(ok))?;
        }
        if let Some(cancel) = &self.cancel {
            pinentry.send_request("SETCANCEL", Some(cancel))?;
        }
        if let Some((confirmation_prompt, mismatch_error)) = &self.confirmation {
            pinentry.send_request("SETREPEAT", Some(confirmation_prompt))?;
            pinentry.send_request("SETREPEATERROR", Some(mismatch_error))?;
        }
        if let Some(timeout) = self.timeout {
            pinentry.send_request("SETTIMEOUT", Some(&format!("{}", timeout)))?;
        }
        loop {
            match (pinentry.send_request("GETPIN", None)?, self.required) {
                // If the user provides an empty passphrase, GETPIN returns no data.
                (None, None) => return Ok(SecretString::new(String::new())),
                (Some(passphrase), _) => return Ok(passphrase),
                (_, Some(empty_error)) => {
                    // SETERROR is cleared by GETPIN, so we reset it on each loop.
                    pinentry.send_request("SETERROR", Some(empty_error))?;
                }
            }
        }
    }
pub fn interact ( & self ) -> Result < SecretString > { let mut pinentry = assuan :: Connection :: open ( & self . binary ) ? ; if let Some ( title ) = & self . title { pinentry . send_request ( " " , Some ( title ) ) ? ; } if let Some ( desc ) = & self . description { pinentry . send_request ( " " , Some ( desc ) ) ? ; } if let Some ( error ) = & self . error { pinentry . send_request ( " " , Some ( error ) ) ? ; } if let Some ( prompt ) = & self . prompt { pinentry . send_request ( " " , Some ( prompt ) ) ? ; } if let Some ( ok ) = & self . ok { pinentry . send_request ( " " , Some ( ok ) ) ? ; } if let Some ( cancel ) = & self . cancel { pinentry . send_request ( " " , Some ( cancel ) ) ? ; } if let Some ( ( confirmation_prompt , mismatch_error ) ) = & self . confirmation { pinentry . send_request ( " " , Some ( confirmation_prompt ) ) ? ; pinentry . send_request ( " " , Some ( mismatch_error ) ) ? ; } if let Some ( timeout ) = self . timeout { pinentry . send_request ( " " , Some ( & format ! ( " " timeout ) ) ) ? ; } loop { match ( pinentry . send_request ( " " , None ) ? , self . required ) { // If the user provides an empty passphrase, GETPIN returns no data. ( None , None ) => return Ok ( SecretString :: new ( String :: new ( ) ) ) , ( Some ( passphrase ) , _ ) => return Ok ( passphrase ) , ( _ , Some ( empty_error ) ) => { // SETERROR is cleared by GETPIN, so we reset it on each loop. pinentry . send_request ( " " , Some ( empty_error ) ) ? ; } } } }
Asks for a passphrase or PIN.
Asks for a passphrase or PIN .
&self