Skip to content

Commit

Permalink
core: Add Client enum
Browse files Browse the repository at this point in the history
This enum can be used in const assertions to ensure that all required
crate features have been selected, for example in backends.
  • Loading branch information
robin-nitrokey committed Dec 19, 2024
1 parent c28febf commit e229e33
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,44 @@ impl Default for StorageAttributes {
}
}

/// Available client traits.
///
/// This enum does not provide access to the trait features. It is only intended for backends to
/// use in constant assertions to ensure that the correct features are enabled.
#[non_exhaustive]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Client {
AttestationClient,
CertificateClient,
CounterClient,
CryptoClient,
FilesystemClient,
ManagementClient,
UiClient,
}

impl Client {
/// All enabled clients.
///
/// The contents of this constant depends on the enabled features.
pub const ENABLED: &[Self] = &[
#[cfg(feature = "attestation-client")]
Self::AttestationClient,
#[cfg(feature = "certificate-client")]
Self::CertificateClient,
#[cfg(feature = "counter-client")]
Self::CounterClient,
#[cfg(feature = "crypto-client")]
Self::CryptoClient,
#[cfg(feature = "filesystem-client")]
Self::FilesystemClient,
#[cfg(feature = "management-client")]
Self::ManagementClient,
#[cfg(feature = "ui-client")]
Self::UiClient,
];
}

#[derive(Copy, Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Mechanism {
Expand Down

0 comments on commit e229e33

Please sign in to comment.