Skip to content

Commit 2ef6757

Browse files
cfsctl: use #[tokio::main]
Let's just have an `async fn main()` instead of doing this ourselves. This also gets us access to the multithreaded executor, which we'll start using soon. Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent 2de9db1 commit 2ef6757

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sha2 = "0.10.1"
3434
tar = { version = "0.4.38", default-features = false }
3535
tempfile = "3.8.0"
3636
thiserror = "2.0.0"
37-
tokio = "1.24.2"
37+
tokio = { version = "1.24.2", features = ["rt-multi-thread"] }
3838
toml = "0.8.0"
3939
xxhash-rust = { version = "0.8.2", features = ["xxh32"] }
4040
zerocopy = { version = "0.8.0", features = ["derive", "std"] }

src/bin/cfsctl.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ enum Command {
106106
},
107107
}
108108

109-
fn main() -> Result<()> {
109+
#[tokio::main]
110+
async fn main() -> Result<()> {
110111
env_logger::init();
111112

112113
let args = App::parse();
@@ -158,12 +159,7 @@ fn main() -> Result<()> {
158159
println!("{}", image_id.to_hex());
159160
}
160161
OciCommand::Pull { ref image, name } => {
161-
let runtime = tokio::runtime::Builder::new_current_thread()
162-
.enable_all()
163-
.build()
164-
.expect("Failed to build tokio runtime");
165-
// And invoke the async_main
166-
runtime.block_on(async move { oci::pull(&repo, image, name.as_deref()).await })?;
162+
oci::pull(&repo, image, name.as_deref()).await?
167163
}
168164
OciCommand::Seal { verity, ref name } => {
169165
let (sha256, verity) = oci::seal(

0 commit comments

Comments
 (0)