Bug: Fails to build with rust 1.77.0



### Bug Description

I have the following error with rust 1.77.0:
```
  --- stderr                                                                                  
  thread 'main' panicked at crates/router_env/src/cargo_workspace.rs:57:5:
  Unknown workspace members package ID format. Please run `cargo metadata --format-version=1 | jq '.workspace_members'` and update this build script to match the updated package ID format.
```

The format of ids in 'cargo metadata' has changed with cargo 1.77, it's documented here: https://github.com/rust-lang/cargo/issues/13528

### Expected Behavior

It should build.

### Actual Behavior

It fails to build.

### Steps To Reproduce

exec `cargo build` with rust 1.77.0

### Context For The Bug

```
  --- stderr                                                                                  
  thread 'main' panicked at crates/router_env/src/cargo_workspace.rs:57:5:
  Unknown workspace members package ID format. Please run `cargo metadata --format-version=1 | jq '.workspace_members'` and update this build script to match the updated package ID format.
```

### Environment

If not (or if building/running locally), please provide the following details:
1. Operating System: FreeBSD
2. Rust version (output of `rustc --version`): ```rustc 1.77.0 (aedd173a2 2024-03-17) (built from a source tarball)
binary: rustc
commit-hash: aedd173a2c086e558c2b66d3743b344f977621a7
commit-date: 2024-03-17
host: x86_64-unknown-freebsd
release: 1.77.0
LLVM version: 17.0.6```
3. App version (output of `cargo r --features vergen -- --version`): ``


### Have you spent some time checking if this bug has been raised before?

- [X] I checked and didn't find a similar issue

### Have you read the Contributing Guidelines?

- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!
diff --git a/Cargo.lock b/Cargo.lock
index 03f78686981..33327b71589 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1764,9 +1764,9 @@ dependencies = [
 
 [[package]]
 name = "cargo_metadata"
-version = "0.15.4"
+version = "0.18.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a"
+checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
 dependencies = [
  "camino",
  "cargo-platform",
@@ -5690,7 +5690,7 @@ dependencies = [
 name = "router_env"
 version = "0.1.0"
 dependencies = [
- "cargo_metadata 0.15.4",
+ "cargo_metadata 0.18.1",
  "config",
  "error-stack",
  "gethostname",
diff --git a/crates/router_env/Cargo.toml b/crates/router_env/Cargo.toml
index 3a4dcf128be..a028dfb8e56 100644
--- a/crates/router_env/Cargo.toml
+++ b/crates/router_env/Cargo.toml
@@ -8,7 +8,7 @@ readme = "README.md"
 license.workspace = true
 
 [dependencies]
-cargo_metadata = "0.15.4"
+cargo_metadata = "0.18.1"
 config = { version = "0.13.3", features = ["toml"] }
 error-stack = "0.3.1"
 gethostname = "0.4.3"
@@ -34,7 +34,7 @@ vergen = { version = "8.2.1", optional = true, features = ["cargo", "git", "git2
 tokio = { version = "1.36.0", features = ["macros", "rt-multi-thread"] }
 
 [build-dependencies]
-cargo_metadata = "0.15.4"
+cargo_metadata = "0.18.1"
 vergen = { version = "8.2.1", features = ["cargo", "git", "git2", "rustc"], optional = true }
 
 [features]
diff --git a/crates/router_env/src/cargo_workspace.rs b/crates/router_env/src/cargo_workspace.rs
index 3fd92fc57c4..fd4ce38712a 100644
--- a/crates/router_env/src/cargo_workspace.rs
+++ b/crates/router_env/src/cargo_workspace.rs
@@ -14,17 +14,11 @@ pub fn set_cargo_workspace_members_env() {
     let metadata = cargo_metadata::MetadataCommand::new()
         .exec()
         .expect("Failed to obtain cargo metadata");
-    let workspace_members = metadata.workspace_members;
 
-    let workspace_members = workspace_members
+    let workspace_members = metadata
+        .workspace_packages()
         .iter()
-        .map(|package_id| {
-            package_id
-                .repr
-                .split_once(' ')
-                .expect("Unknown cargo metadata package ID format")
-                .0
-        })
+        .map(|package| package.name.as_str())
         .collect::<Vec<_>>()
         .join(",");
 
@@ -35,7 +29,7 @@ pub fn set_cargo_workspace_members_env() {
     .expect("Failed to set `CARGO_WORKSPACE_MEMBERS` environment variable");
 }
 
-/// Verify that the cargo metadata workspace members format matches that expected by
+/// Verify that the cargo metadata workspace packages format matches that expected by
 /// [`set_cargo_workspace_members_env`] to set the `CARGO_WORKSPACE_MEMBERS` environment variable.
 ///
 /// This function should be typically called within build scripts, before the
@@ -43,24 +37,20 @@ pub fn set_cargo_workspace_members_env() {
 ///
 /// # Panics
 ///
-/// Panics if running the `cargo metadata` command fails, or if the workspace members package ID
-/// format cannot be determined.
+/// Panics if running the `cargo metadata` command fails, or if the workspace member package names
+/// cannot be determined.
 pub fn verify_cargo_metadata_format() {
     #[allow(clippy::expect_used)]
     let metadata = cargo_metadata::MetadataCommand::new()
         .exec()
         .expect("Failed to obtain cargo metadata");
-    let workspace_members = metadata.workspace_members;
 
-    let package_id_entry_prefix =
-        format!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
     assert!(
-        workspace_members
+        metadata
+            .workspace_packages()
             .iter()
-            .any(|package_id| package_id.repr.starts_with(&package_id_entry_prefix)),
-        "Unknown workspace members package ID format. \
-         Please run `cargo metadata --format-version=1 | jq '.workspace_members'` and update this \
-         build script to match the updated package ID format."
+            .any(|package| package.name == env!("CARGO_PKG_NAME")),
+        "Unable to determine workspace member package names from `cargo metadata`"
     );
 }
 

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [x] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
This PR updates the build script code to obtain cargo workspace member package names to use a better and more deterministic way to do so. 

Previously, we used to perform string manipulation on the package ID format (obtained from the `workspace_members` field in `cargo metadata --format-version=1`), and the package ID format was not stabilized (until recently). The package ID format has been [stabilized](https://github.com/rust-lang/cargo/pull/12914) in Rust 1.77, and the stabilized format breaks our existing build scripts. This PR updates the build script code to instead obtain the workspace member package names using the [`Metadata::workspace_packages()`](https://docs.rs/cargo_metadata/0.18.1/cargo_metadata/struct.Metadata.html#method.workspace_packages) method that the `cargo_metadata` crate provides.

## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->
This would fix builds from breaking once Rust 1.77 is released as the stable version on March 21st, 2024.

Fixes #4137.

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
`cargo run` was successful with both Rust 1.76 and 1.77 (although with warnings).

I installed the Rust 1.77 toolchain by following the instructions from the [Rust 1.77.0 pre-release testing](https://blog.rust-lang.org/inside-rust/2024/03/17/1.77.0-prerelease.html) blog post.

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
