From e229e33e7eeef443719b8b0cba83a0ea8e117488 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 16 Dec 2024 15:01:42 +0100 Subject: [PATCH] core: Add Client enum This enum can be used in const assertions to ensure that all required crate features have been selected, for example in backends. --- core/src/types.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/core/src/types.rs b/core/src/types.rs index 9b136448db6..5d6798449e6 100644 --- a/core/src/types.rs +++ b/core/src/types.rs @@ -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 {