pub trait Callbacks<E> {
    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

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.

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.

  • message is the request or call-to-action to be displayed to the user.
  • yes_string and (optionally) no_string will be displayed on buttons or next to selection options in the user’s UI.

Returns:

  • Ok(true) if the user selected the option marked with yes_string.
  • Ok(false) if the user selected the option marked with no_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.

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.

Requests a secret value from the user, such as a passphrase.

message will be displayed to the user, providing context for the request.

Sends an error.

Note: This API may be removed in a subsequent API refactor, after we’ve figured out how errors should be handled overall, and how to distinguish between hard and soft errors.

Implementors