fn create_computed_topic_spec_from_k8_spec(k8_topic_spec: &K8TopicSpec) -> TopicSpec {

    if let Some(k8_replica_assign) = &k8_topic_spec.custom_replica_assignment {
        // Assigned Topic
        let mut partition_map: Vec<PartitionMap> = vec![];

        for k8_partition in k8_replica_assign {
            partition_map.push(PartitionMap {
                id: k8_partition.id(),
                replicas: k8_partition.replicas().clone(),
            });
        }

        TopicSpec::new_assigned(partition_map)

    } else {
        // Computed Topic
        let partitions = match k8_topic_spec.partitions {
            Some(partitions) => partitions,
            None => -1,
        };

        let replication_factor = match k8_topic_spec.replication_factor {
            Some(replication_factor) => replication_factor,
            None => -1,
        };

        TopicSpec::new_computed(
            partitions,
            replication_factor,
            k8_topic_spec.ignore_rack_assignment,
        )
    }

}
/// There are 2 types of topic configurations:
///  * Computed
///     - computed topics take partitions and replication factor
///  * Assigned
///     - assigned topics take custom replica assignment
///     - partitions & replica factor are derived
///
/// If all parameters are provided, Assigned topics takes precedence.
///  * Values provided for partitions and replication factor are overwritten by the
///    values derived from custom replica assignment.
There are 2 types of topic configurations:
Computed
computed topics take partitions and replication factor
Assigned
assigned topics take custom replica assignment
partitions & replica factor are derived

If all parameters are provided, Assigned topics takes precedence.
Values provided for partitions and replication factor are overwritten by the
values derived from custom replica assignment.
There are 2 types of topic configurations : Computed computed topics take partitions and replication factor Assigned assigned topics take custom replica assignment partitions & replica factor are derived If all parameters are provided Assigned topics takes precedence . Values provided for partitions and replication factor are overwritten by the values derived from custom replica assignment .
fn create_computed_topic_spec_from_k8_spec(k8_topic_spec: &K8TopicSpec) -> TopicSpec {
    if let Some(k8_replica_assign) = &k8_topic_spec.custom_replica_assignment {
        // Assigned Topic
        let mut partition_map: Vec<PartitionMap> = vec![];
        for k8_partition in k8_replica_assign {
            partition_map.push(PartitionMap {
                id: k8_partition.id(),
                replicas: k8_partition.replicas().clone(),
            });
        }
        TopicSpec::new_assigned(partition_map)
    } else {
        // Computed Topic
        let partitions = match k8_topic_spec.partitions {
            Some(partitions) => partitions,
            None => -1,
        };
        let replication_factor = match k8_topic_spec.replication_factor {
            Some(replication_factor) => replication_factor,
            None => -1,
        };
        TopicSpec::new_computed(
            partitions,
            replication_factor,
            k8_topic_spec.ignore_rack_assignment,
        )
    }
}
fn create_computed_topic_spec_from_k8_spec ( k8_topic_spec : & K8TopicSpec ) -> TopicSpec { if let Some ( k8_replica_assign ) = & k8_topic_spec . custom_replica_assignment { // Assigned Topic let mut partition_map : Vec < PartitionMap > = vec ! [ ] ; for k8_partition in k8_replica_assign { partition_map . push ( PartitionMap { id : k8_partition . id ( ) , replicas : k8_partition . replicas ( ) . clone ( ) , } ) ; } TopicSpec :: new_assigned ( partition_map ) } else { // Computed Topic let partitions = match k8_topic_spec . partitions { Some ( partitions ) => partitions , None => - 1 , } ; let replication_factor = match k8_topic_spec . replication_factor { Some ( replication_factor ) => replication_factor , None => - 1 , } ; TopicSpec :: new_computed ( partitions , replication_factor , k8_topic_spec . ignore_rack_assignment , ) } }
There are 2 types of topic configurations:
 Computed
 computed topics take partitions and replication factor
 Assigned
 assigned topics take custom replica assignment
 partitions & replica factor are derived
There are 2 types of topic configurations : Computed computed topics take partitions and replication factor Assigned assigned topics take custom replica assignment partitions & replica factor are derived
k8_topic_spec
&K8TopicSpec
k8_topic_spec
&K8TopicSpec