/// Create a new [`Database`] struct from a set of trusted root keys that are used to verify
/// the signed metadata. The signed root metadata must be signed with at least a
/// `root_threshold` of the provided root_keys. It is not necessary for the root metadata to
/// contain these keys.
Create a new [`Database`] struct from a set of trusted root keys that are used to verify
the signed metadata. The signed root metadata must be signed with at least a
`root_threshold` of the provided root_keys. It is not necessary for the root metadata to
contain these keys.
Create a new [ ` Database ` ] struct from a set of trusted root keys that are used to verify the signed metadata . The signed root metadata must be signed with at least a ` root_threshold ` of the provided root_keys . It is not necessary for the root metadata to contain these keys .
pub fn from_root_with_trusted_keys<'a, I>(
        raw_root: &RawSignedMetadata<D, RootMetadata>,
        root_threshold: u32,
        root_keys: I,
    ) -> Result<Self>
    where
        I: IntoIterator<Item = &'a PublicKey>,
    {
        let verified_root = {
            // Make sure the keys signed the root.
            let new_root = verify::verify_signatures(raw_root, root_threshold, root_keys)?;
            // Make sure the root signed itself.
            let verified_root = verify::verify_signatures(
                raw_root,
                new_root.root().threshold(),
                new_root.keys().iter().filter_map(|(k, v)| {
                    if new_root.root().key_ids().contains(k) {
                        Some(v)
                    } else {
                        None
                    }
                }),
            )?;
            verified_root
        };
        Ok(Database {
            trusted_root: verified_root,
            trusted_snapshot: None,
            trusted_targets: None,
            trusted_timestamp: None,
            trusted_delegations: HashMap::new(),
            interchange: PhantomData,
        })
    }
pub fn from_root_with_trusted_keys < ' a , I > ( raw_root : & RawSignedMetadata < D , RootMetadata > , root_threshold : u32 , root_keys : I , ) -> Result < Self > where I : IntoIterator < Item = & ' a PublicKey > , { let verified_root = { // Make sure the keys signed the root. let new_root = verify :: verify_signatures ( raw_root , root_threshold , root_keys ) ? ; // Make sure the root signed itself. let verified_root = verify :: verify_signatures ( raw_root , new_root . root ( ) . threshold ( ) , new_root . keys ( ) . iter ( ) . filter_map ( | ( k , v ) | { if new_root . root ( ) . key_ids ( ) . contains ( k ) { Some ( v ) } else { None } } ) , ) ? ; verified_root } ; Ok ( Database { trusted_root : verified_root , trusted_snapshot : None , trusted_targets : None , trusted_timestamp : None , trusted_delegations : HashMap :: new ( ) , interchange : PhantomData , } ) }
Create a new [`Database`] struct from a set of trusted root keys that are used to verify
the signed metadata.
Create a new [ ` Database ` ] struct from a set of trusted root keys that are used to verify the signed metadata .
raw_root
&RawSignedMetadata<D, RootMetadata>
root_threshold
u32
root_keys
I