pub fn add(
        &mut self,
        p: crate::Primitive,
        key: &crate::proto::keyset::Key,
    ) -> Result<Entry, TinkError> {
        if key.status != crate::proto::KeyStatusType::Enabled as i32 {
            return Err("The key must be ENABLED".into());
        }
        let prefix =
            crate::cryptofmt::output_prefix(key).map_err(|e| wrap_err("primitiveset", e))?;
        let entry = Entry::new(
            key.key_id,
            p,
            &prefix,
            crate::proto::OutputPrefixType::from_i32(key.output_prefix_type)
                .ok_or_else(|| TinkError::new("invalid key prefix type"))?,
            crate::proto::KeyStatusType::from_i32(key.status)
                .ok_or_else(|| TinkError::new("invalid key status"))?,
        );
        let retval = entry.clone();
        match self.entries.entry(prefix) {
            hash_map::Entry::Occupied(mut oe) => oe.get_mut().push(entry),
            hash_map::Entry::Vacant(ve) => {
                ve.insert(vec![entry]);
            }
        };
        Ok(retval)
    }
/// Create a new entry in the primitive set and returns a copy of the added entry.
Create a new entry in the primitive set and returns a copy of the added entry.
Create a new entry in the primitive set and returns a copy of the added entry .
pub fn add(
        &mut self,
        p: crate::Primitive,
        key: &crate::proto::keyset::Key,
    ) -> Result<Entry, TinkError> {
        if key.status != crate::proto::KeyStatusType::Enabled as i32 {
            return Err("The key must be ENABLED".into());
        }
        let prefix =
            crate::cryptofmt::output_prefix(key).map_err(|e| wrap_err("primitiveset", e))?;
        let entry = Entry::new(
            key.key_id,
            p,
            &prefix,
            crate::proto::OutputPrefixType::from_i32(key.output_prefix_type)
                .ok_or_else(|| TinkError::new("invalid key prefix type"))?,
            crate::proto::KeyStatusType::from_i32(key.status)
                .ok_or_else(|| TinkError::new("invalid key status"))?,
        );
        let retval = entry.clone();
        match self.entries.entry(prefix) {
            hash_map::Entry::Occupied(mut oe) => oe.get_mut().push(entry),
            hash_map::Entry::Vacant(ve) => {
                ve.insert(vec![entry]);
            }
        };
        Ok(retval)
    }
pub fn add ( & mut self , p : crate :: Primitive , key : & crate :: proto :: keyset :: Key , ) -> Result < Entry , TinkError > { if key . status != crate :: proto :: KeyStatusType :: Enabled as i32 { return Err ( " " . into ( ) ) ; } let prefix = crate :: cryptofmt :: output_prefix ( key ) . map_err ( | e | wrap_err ( " " , e ) ) ? ; let entry = Entry :: new ( key . key_id , p , & prefix , crate :: proto :: OutputPrefixType :: from_i32 ( key . output_prefix_type ) . ok_or_else ( | | TinkError :: new ( " " ) ) ? , crate :: proto :: KeyStatusType :: from_i32 ( key . status ) . ok_or_else ( | | TinkError :: new ( " " ) ) ? , ) ; let retval = entry . clone ( ) ; match self . entries . entry ( prefix ) { hash_map :: Entry :: Occupied ( mut oe ) => oe . get_mut ( ) . push ( entry ) , hash_map :: Entry :: Vacant ( ve ) => { ve . insert ( vec ! [ entry ] ) ; } } ; Ok ( retval ) }
Create a new entry in the primitive set and returns a copy of the added entry.
Create a new entry in the primitive set and returns a copy of the added entry .
&mut self
p
crate::Primitive
key
&crate::proto::keyset::Key