fix(stream): change IPC packet

pull/2479/head
adrieljss 5 months ago
parent fd7bd417e1
commit ca3651b55d
No known key found for this signature in database
GPG Key ID: 849F13CBD0B4AD05

20
Cargo.lock generated

@ -1847,7 +1847,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@ -3349,7 +3349,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
"windows-targets 0.48.5",
"windows-targets 0.52.6",
]
[[package]]
@ -4840,7 +4840,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@ -5524,6 +5524,15 @@ dependencies = [
"typeid",
]
[[package]]
name = "serde_bytes"
version = "0.11.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a"
dependencies = [
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.215"
@ -6667,6 +6676,7 @@ dependencies = [
"reqwest",
"schemars",
"serde",
"serde_bytes",
"serde_json",
"tauri",
"tauri-plugin",
@ -7096,7 +7106,7 @@ dependencies = [
"fastrand",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@ -8126,7 +8136,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]

@ -30,6 +30,7 @@ regex = "1"
[dependencies]
serde = { workspace = true }
serde_bytes = "0.11"
serde_json = { workspace = true }
tauri = { workspace = true }
thiserror = { workspace = true }

@ -131,8 +131,8 @@ pub struct BasicAuth {
#[derive(Clone, Serialize)]
pub struct StreamMessage {
value: Option<Vec<u8>>,
done: bool,
#[serde(with = "serde_bytes")]
bytes: Vec<u8>
}
#[inline]
@ -329,13 +329,11 @@ pub async fn fetch<R: Runtime>(
// send response through IPC channel
while let Some(chunk) = res.chunk().await? {
stream_channel.send(StreamMessage{
value: Some(chunk.to_vec()),
done: false,
})?;
stream_channel.send(StreamMessage{bytes: chunk.to_vec()})?;
}
stream_channel.send(StreamMessage { value: None, done: true })?;
// send empty vector when done
stream_channel.send(StreamMessage{bytes: Vec::new()})?;
// return that response
Ok(res)

Loading…
Cancel
Save