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

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

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

Loading…
Cancel
Save