Skip to content

feat: allow collecting raw output from sidecars #3090

@niusia-ua

Description

@niusia-ua

In the tauri_plugin_shell::process::Command, we have the output method which automatically collects all output from the sidecar command. The issue with it is that it inserts \n after each received chunk. In case of handling raw output (i.e. binary output; for example, images, PDFs, etc.), this behavior breaks the received buffer.

It would be nice to have a boolean parameter or a separate method for collecting the output without inserting \n between chunks.

pub async fn output(self) -> crate::Result<Output> {
let (mut rx, _child) = self.spawn()?;
let mut code = None;
let mut stdout = Vec::new();
let mut stderr = Vec::new();
while let Some(event) = rx.recv().await {
match event {
CommandEvent::Terminated(payload) => {
code = payload.code;
}
CommandEvent::Stdout(line) => {
stdout.extend(line);
stdout.push(NEWLINE_BYTE);
}
CommandEvent::Stderr(line) => {
stderr.extend(line);
stderr.push(NEWLINE_BYTE);
}
CommandEvent::Error(_) => {}
}
}
Ok(Output {
status: ExitStatus { code },
stdout,
stderr,
})
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions