From 0aee46115625335c2fc6407ebc628345030a21b4 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Mon, 19 Jun 2023 10:14:46 +0700 Subject: [PATCH] Use tokio file --- src/image/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/image/mod.rs b/src/image/mod.rs index 11e2e0a..e9deee4 100644 --- a/src/image/mod.rs +++ b/src/image/mod.rs @@ -12,6 +12,7 @@ use anyhow::{Context, Result}; use log::*; use neolink_core::{bc_protocol::*, bcmedia::model::*}; +use tokio::{fs::File, io::AsyncWriteExt}; mod cmdline; mod gst; @@ -76,9 +77,9 @@ pub(crate) async fn main(opt: Opt, config: Config) -> Result<()> { // Simply use the snap command debug!("Using the snap command"); let file_path = opt.file_path.with_extension("jpeg"); - let mut buffer = File::create(file_path)?; + let mut buffer = File::create(file_path).await?; let jpeg_data = camera.get_snapshot().await?; - buffer.write_all(jpeg_data)?; + buffer.write_all(jpeg_data.as_slice()).await?; } Ok(())