pub trait Callbacks<E> {
// Required methods
fn message(&mut self, message: &str) -> Result<()>;
fn confirm(
&mut self,
message: &str,
yes_string: &str,
no_string: Option<&str>,
) -> Result<bool>;
fn request_public(&mut self, message: &str) -> Result<String>;
fn request_secret(&mut self, message: &str) -> Result<SecretString>;
fn error(&mut self, error: E) -> Result<()>;
}Expand description
The interface that age plugins can use to interact with an age implementation.
Required Methods§
Sourcefn message(&mut self, message: &str) -> Result<()>
fn message(&mut self, message: &str) -> Result<()>
Shows a message to the user.
This can be used to prompt the user to take some physical action, such as inserting a hardware key.
Sourcefn confirm(
&mut self,
message: &str,
yes_string: &str,
no_string: Option<&str>,
) -> Result<bool>
fn confirm( &mut self, message: &str, yes_string: &str, no_string: Option<&str>, ) -> Result<bool>
Requests that the user provides confirmation for some action.
This can be used to, for example, request that a hardware key the plugin wants to try either be plugged in, or skipped.
messageis the request or call-to-action to be displayed to the user.yes_stringand (optionally)no_stringwill be displayed on buttons or next to selection options in the user’s UI.
Returns:
Ok(true)if the user selected the option marked withyes_string.Ok(false)if the user selected the option marked withno_string(or the default negative confirmation label).Err(Error::Fail)if the confirmation request could not be given to the user (for example, if there is no UI for displaying messages).Err(Error::Unsupported)if the user’s client does not support this callback.
Sourcefn request_public(&mut self, message: &str) -> Result<String>
fn request_public(&mut self, message: &str) -> Result<String>
Requests a non-secret value from the user.
message will be displayed to the user, providing context for the request.
To request secrets, use Callbacks::request_secret.
Sourcefn request_secret(&mut self, message: &str) -> Result<SecretString>
fn request_secret(&mut self, message: &str) -> Result<SecretString>
Requests a secret value from the user, such as a passphrase.
message will be displayed to the user, providing context for the request.