Repository: qdrant/qdrant
File: lib/collection/src/operations/conversions.rs (Rust)

Code before:
impl From<ReshardingDirection> for api::grpc::qdrant::ReshardingDirection {
    fn from(value: ReshardingDirection) -> Self {
        match value {
            ReshardingDirection::Up => api::grpc::qdrant::ReshardingDirection::Up,
            ReshardingDirection::Down => api::grpc::qdrant::ReshardingDirection::Down,
        }
    }
}

impl From<CollectionShardKeys> for Vec<api::grpc::qdrant::ShardKey> {
    fn from(value: CollectionShardKeys) -> Self {
        value
            .shard_keys
            .into_iter()
            .map(|k| {
                let key = match k {
                    ShardKey::Keyword(k) => {
                        api::grpc::qdrant::shard_key::Key::Keyword(k.to_string())
                    }
                    ShardKey::Number(n) => api::grpc::qdrant::shard_key::Key::Number(n),
                };
                api::grpc::qdrant::ShardKey { key: Some(key) }
            })
            .collect()
    }
}

impl From<ShardTransferInfo> for api::grpc::qdrant::ShardTransferInfo {
    fn from(value: ShardTransferInfo) -> Self {
        let ShardTransferInfo {
            shard_id,
            to_shard_id,
            from,
            to,
            sync,
            method: _,
            comment: _,
        } = value;
        Self {
            shard_id,
            to_shard_id,
            from,
            to,
            sync,
        }
    }
}

impl From<CollectionClusterInfo> for api::grpc::qdrant::CollectionClusterInfoResponse {
    fn from(value: CollectionClusterInfo) -> Self {
        let CollectionClusterInfo {

Review comment (suggestion):
nit: There should be a direct conversion from `segment::types::ShardKey` to `api::grpc::qdrant::ShardKey`, and then use it here.

Code after:
impl From<ReshardingDirection> for api::grpc::qdrant::ReshardingDirection {
    fn from(value: ReshardingDirection) -> Self {
        match value {
            ReshardingDirection::Up => api::grpc::qdrant::ReshardingDirection::Up,
            ReshardingDirection::Down => api::grpc::qdrant::ReshardingDirection::Down,
        }
    }
}

impl From<ShardTransferInfo> for api::grpc::qdrant::ShardTransferInfo {
    fn from(value: ShardTransferInfo) -> Self {
        let ShardTransferInfo {
            shard_id,
            to_shard_id,
            from,
            to,
            sync,
            method: _,
            comment: _,
        } = value;
        Self {
            shard_id,
            to_shard_id,
            from,
            to,
            sync,
        }
    }
}

impl From<CollectionClusterInfo> for api::grpc::qdrant::CollectionClusterInfoResponse {
    fn from(value: CollectionClusterInfo) -> Self {
        let CollectionClusterInfo {
            peer_id,
            shard_count,
            local_shards,
            remote_shards,
            shard_transfers,
            resharding_operations,
        } = value;
        Self {
            peer_id,
            shard_count: shard_count as u64,
            local_shards: local_shards.into_iter().map(|shard| shard.into()).collect(),
            remote_shards: remote_shards
                .into_iter()
                .map(|shard| shard.into())
                .collect(),
            shard_transfers: shard_transfers
                .into_iter()
                .map(|shard| shard.into())