pub fn add_kdf<K>(&mut self, kdf_name: &str) -> &mut Self
    where
        K: DeriveKey + DeserializeOwned + Default,
    {
        let factory = |options| {
            let kdf: K = serde_json::from_value(options)?;
            Ok(Box::new(kdf) as Box<dyn DeriveKey>)
        };

        let old_kdf = self.kdfs.insert(kdf_name.to_owned(), Box::new(factory));
        assert!(
            old_kdf.is_none(),
            "cipher name already registered: {}",
            kdf_name
        );

        let old_name = self
            .kdf_names
            .insert(TypeId::of::<K>(), kdf_name.to_owned());
        if let Some(old_name) = old_name {
            panic!(
                "KDF {} already registered under name {}",
                kdf_name, old_name
            );
        }

        self
    }
/// Adds a key derivation function.
///
/// # Panics
///
/// Panics if the KDF is already registered under a different name, or if `kdf_name`
/// is already registered.
Adds a key derivation function.
Adds a key derivation function .
pub fn add_kdf<K>(&mut self, kdf_name: &str) -> &mut Self
    where
        K: DeriveKey + DeserializeOwned + Default,
    {
        let factory = |options| {
            let kdf: K = serde_json::from_value(options)?;
            Ok(Box::new(kdf) as Box<dyn DeriveKey>)
        };
        let old_kdf = self.kdfs.insert(kdf_name.to_owned(), Box::new(factory));
        assert!(
            old_kdf.is_none(),
            "cipher name already registered: {}",
            kdf_name
        );
        let old_name = self
            .kdf_names
            .insert(TypeId::of::<K>(), kdf_name.to_owned());
        if let Some(old_name) = old_name {
            panic!(
                "KDF {} already registered under name {}",
                kdf_name, old_name
            );
        }
        self
    }
pub fn add_kdf < K > ( & mut self , kdf_name : & str ) -> & mut Self where K : DeriveKey + DeserializeOwned + Default , { let factory = | options | { let kdf : K = serde_json :: from_value ( options ) ? ; Ok ( Box :: new ( kdf ) as Box < dyn DeriveKey > ) } ; let old_kdf = self . kdfs . insert ( kdf_name . to_owned ( ) , Box :: new ( factory ) ) ; assert ! ( old_kdf is_none ( ) " " kdf_name ) ; let old_name = self . kdf_names . insert ( TypeId :: of :: < K > ( ) , kdf_name . to_owned ( ) ) ; if let Some ( old_name ) = old_name { panic ! ( " " kdf_name old_name ) ; } self }
Adds a key derivation function.
Adds a key derivation function .
&mut self
kdf_name
&str
&mut self
kdf_name
&str
panics
Panics if the KDF is already registered under a different name, or if `kdf_name`
is already registered.
Panics if the KDF is already registered under a different name or if ` kdf_name ` is already registered .