DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/Air/AirClient/
DownloadStream.rs1#[cfg(feature = "AirIntegration")]
7use CommonLibrary::Error::CommonError::CommonError;
8
9#[cfg(feature = "AirIntegration")]
10use crate::{Air::AirClient::DownloadStreamChunk, dev_log};
11
12#[cfg(feature = "AirIntegration")]
13pub struct Struct {
14 inner:tonic::codec::Streaming<AirLibrary::Vine::Generated::air::DownloadStreamResponse>,
15}
16
17#[cfg(feature = "AirIntegration")]
18impl Struct {
19 pub fn new(Stream:tonic::codec::Streaming<AirLibrary::Vine::Generated::air::DownloadStreamResponse>) -> Self {
20 Self { inner:Stream }
21 }
22
23 pub async fn next(&mut self) -> Option<Result<DownloadStreamChunk::Struct, CommonError>> {
25 match futures_util::stream::StreamExt::next(&mut self.inner).await {
26 Some(Ok(Response)) => {
27 Some(Ok(DownloadStreamChunk::Struct {
28 data:Response.chunk,
29 total_size:Response.total_size,
30 downloaded:Response.downloaded,
31 completed:Response.completed,
32 error:Response.error,
33 }))
34 },
35
36 Some(Err(Error)) => {
37 dev_log!("grpc", "error: [DownloadStream] Stream error: {}", Error);
38
39 Some(Err(CommonError::IPCError { Description:format!("Stream error: {}", Error) }))
40 },
41
42 None => None,
43 }
44 }
45}