rtc-crypto 0.21.0-alpha.2

Provider-neutral cryptography for the webrtc-rs RTC stack
Documentation
use std::sync::Arc;

use crate::{CryptoError, RTCCryptoProvider};

/// Constructs the built-in default provider.
///
/// Ring remains the default whenever its feature is enabled. AWS-LC-RS is selected only when it is
/// the sole built-in. With no built-in features this returns [`CryptoError::NoDefaultProvider`].
pub fn default_provider() -> Result<Arc<dyn RTCCryptoProvider>, CryptoError> {
    #[cfg(feature = "crypto-ring")]
    {
        Ok(Arc::new(crate::providers::RingProvider::new()))
    }

    #[cfg(all(not(feature = "crypto-ring"), feature = "crypto-aws-lc-rs"))]
    {
        Ok(Arc::new(crate::providers::AwsLcRsProvider::new()))
    }

    #[cfg(not(any(feature = "crypto-ring", feature = "crypto-aws-lc-rs")))]
    {
        Err(CryptoError::NoDefaultProvider)
    }
}