fn read_policy(r: &ledger_messages::EndorsementRule) -> Expression {
        let min = r.get_min_endorsements();
        let rules = r.get_rules();
        let principals = r.get_principals();

        let mut vec_rules = Vec::new();
        let rules_iter = rules.into_iter();
        for r in rules_iter {
            vec_rules.push(LedgerService::read_policy(&r));
        }

        let principals_iter = principals.into_iter();

        let mut vec_principals = Vec::new();
        for p in principals_iter {
            match p.get_role() {
                ledger_messages::EndorsementPrincipal_Role::MEMBER => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::MEMBER));
                }
                ledger_messages::EndorsementPrincipal_Role::ADMIN => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::PEER));
                }
                ledger_messages::EndorsementPrincipal_Role::CLIENT => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::PEER));
                }
                ledger_messages::EndorsementPrincipal_Role::PEER => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::PEER));
                }
            }
        }

        let num_elements = (vec_principals.len() + vec_rules.len()) as i32;

        if vec_principals.len() == 1 && vec_rules.len() == 0 {
            return vec_principals[0].clone();
        } else if min == 1 {
            let concatenated = [&vec_rules[..], &vec_principals[..]].concat();
            return Expression::OR(concatenated);
        } else if min == num_elements {
            let concatenated = [&vec_rules[..], &vec_principals[..]].concat();
            return Expression::AND(concatenated);
        } else {
            let concatenated = [&vec_rules[..], &vec_principals[..]].concat();
            if min == 0 {
                return concatenated[0].clone();
            } else {
                return Expression::OUTOF(concatenated, min as usize);
            };
        };
    }
/// Function to read the protobuf format and return the Rust Enum
Function to read the protobuf format and return the Rust Enum
Function to read the protobuf format and return the Rust Enum
fn read_policy(r: &ledger_messages::EndorsementRule) -> Expression {
        let min = r.get_min_endorsements();
        let rules = r.get_rules();
        let principals = r.get_principals();
        let mut vec_rules = Vec::new();
        let rules_iter = rules.into_iter();
        for r in rules_iter {
            vec_rules.push(LedgerService::read_policy(&r));
        }
        let principals_iter = principals.into_iter();
        let mut vec_principals = Vec::new();
        for p in principals_iter {
            match p.get_role() {
                ledger_messages::EndorsementPrincipal_Role::MEMBER => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::MEMBER));
                }
                ledger_messages::EndorsementPrincipal_Role::ADMIN => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::PEER));
                }
                ledger_messages::EndorsementPrincipal_Role::CLIENT => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::PEER));
                }
                ledger_messages::EndorsementPrincipal_Role::PEER => {
                    vec_principals.push(Principal(p.get_msp_id().to_string(), ROLE::PEER));
                }
            }
        }
        let num_elements = (vec_principals.len() + vec_rules.len()) as i32;
        if vec_principals.len() == 1 && vec_rules.len() == 0 {
            return vec_principals[0].clone();
        } else if min == 1 {
            let concatenated = [&vec_rules[..], &vec_principals[..]].concat();
            return Expression::OR(concatenated);
        } else if min == num_elements {
            let concatenated = [&vec_rules[..], &vec_principals[..]].concat();
            return Expression::AND(concatenated);
        } else {
            let concatenated = [&vec_rules[..], &vec_principals[..]].concat();
            if min == 0 {
                return concatenated[0].clone();
            } else {
                return Expression::OUTOF(concatenated, min as usize);
            };
        };
    }
fn read_policy ( r : & ledger_messages :: EndorsementRule ) -> Expression { let min = r . get_min_endorsements ( ) ; let rules = r . get_rules ( ) ; let principals = r . get_principals ( ) ; let mut vec_rules = Vec :: new ( ) ; let rules_iter = rules . into_iter ( ) ; for r in rules_iter { vec_rules . push ( LedgerService :: read_policy ( & r ) ) ; } let principals_iter = principals . into_iter ( ) ; let mut vec_principals = Vec :: new ( ) ; for p in principals_iter { match p . get_role ( ) { ledger_messages :: EndorsementPrincipal_Role :: MEMBER => { vec_principals . push ( Principal ( p . get_msp_id ( ) . to_string ( ) , ROLE :: MEMBER ) ) ; } ledger_messages :: EndorsementPrincipal_Role :: ADMIN => { vec_principals . push ( Principal ( p . get_msp_id ( ) . to_string ( ) , ROLE :: PEER ) ) ; } ledger_messages :: EndorsementPrincipal_Role :: CLIENT => { vec_principals . push ( Principal ( p . get_msp_id ( ) . to_string ( ) , ROLE :: PEER ) ) ; } ledger_messages :: EndorsementPrincipal_Role :: PEER => { vec_principals . push ( Principal ( p . get_msp_id ( ) . to_string ( ) , ROLE :: PEER ) ) ; } } } let num_elements = ( vec_principals . len ( ) + vec_rules . len ( ) ) as i32 ; if vec_principals . len ( ) == 1 && vec_rules . len ( ) == 0 { return vec_principals [ 0 ] . clone ( ) ; } else if min == 1 { let concatenated = [ & vec_rules [ .. ] , & vec_principals [ .. ] ] . concat ( ) ; return Expression :: OR ( concatenated ) ; } else if min == num_elements { let concatenated = [ & vec_rules [ .. ] , & vec_principals [ .. ] ] . concat ( ) ; return Expression :: AND ( concatenated ) ; } else { let concatenated = [ & vec_rules [ .. ] , & vec_principals [ .. ] ] . concat ( ) ; if min == 0 { return concatenated [ 0 ] . clone ( ) ; } else { return Expression :: OUTOF ( concatenated , min as usize ) ; } ; } ; }
Function to read the protobuf format and return the Rust Enum
Function to read the protobuf format and return the Rust Enum
r
&ledger_messages::EndorsementRule