wasmer_wasix/journal/effector/syscalls/
tty_set.rs

1use crate::WasiTtyState;
2
3use super::*;
4
5impl JournalEffector {
6    pub fn save_tty_set(
7        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
8        state: WasiTtyState,
9    ) -> anyhow::Result<()> {
10        Self::save_event(
11            ctx,
12            JournalEntry::TtySetV1 {
13                tty: wasmer_wasix_types::wasi::Tty {
14                    cols: state.cols,
15                    rows: state.rows,
16                    width: state.width,
17                    height: state.height,
18                    stdin_tty: state.stdin_tty,
19                    stdout_tty: state.stdout_tty,
20                    stderr_tty: state.stderr_tty,
21                    echo: state.echo,
22                    line_buffered: state.line_buffered,
23                },
24                line_feeds: state.line_feeds,
25            },
26        )
27    }
28
29    pub fn apply_tty_set(
30        ctx: &mut FunctionEnvMut<'_, WasiEnv>,
31        state: WasiTtyState,
32    ) -> anyhow::Result<()> {
33        crate::syscalls::tty_set_internal(ctx, state).map_err(|err| {
34            anyhow::format_err!("journal restore error: failed to set tty - {err}")
35        })?;
36        Ok(())
37    }
38}