You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Capturer::frame() in a async code, which blocks other code because I had to wait until a Frame is returned.
I have tried to run such code with smol::unblock()
use scrap::{CapturerasRealCapturer,Display};pubstructScreenshot{pubcapturer:RealCapturer,}implScreenshot{pubfnnew() -> Result<Self, std::io::Error>{Ok(Self{capturer:RealCapturer::new(Display::primary()?)? })}pubfncapturer_size(&self) -> (usize,usize){(self.capturer.width(),self.capturer.height())}pubasyncfncapture(&mutself) -> Result<Vec<u8>, std::io::Error>{
smol::unblock(|| loop{matchself.capturer.frame(){Ok(frame) => breakOk(frame.to_vec()),// sometimes returns an empty frameErr(e)if e.kind() == std::io::ErrorKind::WouldBlock => {},Err(e) => breakErr(e),}}).await}}
but failed as Capture doesn't implements Send
`*mut winapi::d3d11::ID3D11Device` cannot be sent between threads safely
within `Screenshot`, the trait `std::marker::Send` is not implemented for `*mut winapi::d3d11::ID3D11Device`
required because of the requirements on the impl of `std::marker::Send` for `&mut Screenshot`
1 redundant requirements hidden
required because of the requirements on the impl of `std::marker::Send` for `&mut &mut Screenshot`
required because it appears within the type `[closure@src\screenshot.rs:21:23: 27:10]`
The text was updated successfully, but these errors were encountered:
I'm using
Capturer::frame()
in a async code, which blocks other code because I had to wait until aFrame
is returned.I have tried to run such code with
smol::unblock()
but failed as
Capture
doesn't implementsSend
The text was updated successfully, but these errors were encountered: