/// Find the signing keys and metadata for the delegation given by `role`, as seen from the
/// point of view of `parent_role`.
Find the signing keys and metadata for the delegation given by `role`, as seen from the
point of view of `parent_role`.
Find the signing keys and metadata for the delegation given by ` role ` as seen from the point of view of ` parent_role ` .
fn find_delegation_threshold_and_keys(
        &self,
        parent_role: &MetadataPath,
        role: &MetadataPath,
    ) -> Option<(u32, Vec<&PublicKey>)> {
        // Find the parent TargetsMetadata that is expected to refer to `role`.
        let trusted_parent = {
            if parent_role == &MetadataPath::from_role(&Role::Targets) {
                self.trusted_targets()?
            } else {
                self.trusted_delegations.get(parent_role)?
            }
        };
        // Only consider targets metadata that define delegations.
        let trusted_delegations = match trusted_parent.delegations() {
            Some(d) => d,
            None => return None,
        };
        for trusted_delegation in trusted_delegations.roles() {
            if trusted_delegation.role() != role {
                continue;
            }
            // Filter the delegations keys to just the ones for this delegation.
            let authorized_keys = trusted_delegations
                .keys()
                .iter()
                .filter_map(|(k, v)| {
                    if trusted_delegation.key_ids().contains(k) {
                        Some(v)
                    } else {
                        None
                    }
                })
                .collect();
            return Some((trusted_delegation.threshold(), authorized_keys));
        }
        None
    }
fn find_delegation_threshold_and_keys ( & self , parent_role : & MetadataPath , role : & MetadataPath , ) -> Option < ( u32 , Vec < & PublicKey > ) > { // Find the parent TargetsMetadata that is expected to refer to `role`. let trusted_parent = { if parent_role == & MetadataPath :: from_role ( & Role :: Targets ) { self . trusted_targets ( ) ? } else { self . trusted_delegations . get ( parent_role ) ? } } ; // Only consider targets metadata that define delegations. let trusted_delegations = match trusted_parent . delegations ( ) { Some ( d ) => d , None => return None , } ; for trusted_delegation in trusted_delegations . roles ( ) { if trusted_delegation . role ( ) != role { continue ; } // Filter the delegations keys to just the ones for this delegation. let authorized_keys = trusted_delegations . keys ( ) . iter ( ) . filter_map ( | ( k , v ) | { if trusted_delegation . key_ids ( ) . contains ( k ) { Some ( v ) } else { None } } ) . collect ( ) ; return Some ( ( trusted_delegation . threshold ( ) , authorized_keys ) ) ; } None }
Find the signing keys and metadata for the delegation given by `role`, as seen from the
point of view of `parent_role`.
Find the signing keys and metadata for the delegation given by ` role ` as seen from the point of view of ` parent_role ` .
&self
parent_role
&MetadataPath
role
&MetadataPath