Skip to main content

BackendCheck

Trait BackendCheck 

Source
pub trait BackendCheck {
    // Required methods
    fn is_available(&self) -> bool;
    fn is_provisioned(&self) -> bool;
}
Expand description

An interface for simple checks against a Signstar backend.

Backends may or may not be connected to a given Signstar host. This interface helps to establish whether they should be considered when evaluating state, or not.

§Note

Evaluating the availability and state of an HSM backend maybe subject to transient issues (e.g. network outage, USB connectivity). This is important to keep in mind when relying on BackendCheck::is_available and BackendCheck::is_provisioned in your code!

Required Methods§

Source

fn is_available(&self) -> bool

Checks whether a Signstar backend connection is available on the current host.

This function is meant as a simple check as to whether a backend is available to the Signstar host executing this function, or not.

It is not meant to track specific errors as to why a connection cannot be established. However, implementations are advised to emit meaningful warning and error messages, if a specific failure is encountered with a backend.

§Note

Implementations should only return true, if they are able to establish connection from the current Signstar host. Establishing a connection should ideally happen using unauthenticated functionality of the backend. Calling this function should answer the question “Is the backend connected to this host?”.

§Examples
use signstar_common::traits::BackendCheck;

// A dummy backend, that doesn't do anything.
struct DummyBackend;

impl BackendCheck for DummyBackend {
    /// This backend is always available.
    fn is_available(&self) -> bool {
        true
    }

    /// This backend is always considered provisioned.
    fn is_provisioned(&self) -> bool {
        true
    }
}

let backend = DummyBackend;
assert!(backend.is_available());
Source

fn is_provisioned(&self) -> bool

Checks whether a Signstar backend has been provisioned.

This function is meant as a simple check as to whether a backend is still using factory settings, or not.

It is not meant to track specific errors as to why a connection cannot be established, etc. However, implementations are advised to emit meaningful warning and error messages, if a specific failure is encountered with a backend.

§Note

Implementations should only return true, if they can ensure, that the backend has been altered from its factory settings (indicators for this may differ depending on backend). Calling this function should answer the question “Is the backend connected to this host and is it provisioned?”.

§Examples
use signstar_common::traits::BackendCheck;

// A dummy backend, that doesn't do anything.
struct DummyBackend;

impl BackendCheck for DummyBackend {
    /// This backend is always available.
    fn is_available(&self) -> bool {
        true
    }

    /// This backend is always considered provisioned.
    fn is_provisioned(&self) -> bool {
        true
    }
}

let backend = DummyBackend;
assert!(backend.is_provisioned());

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§