aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/errors.rs
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-02-11 21:15:38 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:47:48 +0530
commit588cdaa00894a9ae46e6a293f73ba62d5b1df18f (patch)
treea75863550610cbea67d4804ef15c26712603674c /src/common/errors.rs
parentdocs(changelog): update change (diff)
downloadsl0ppij-588cdaa00894a9ae46e6a293f73ba62d5b1df18f.tar.gz
sl0ppij-588cdaa00894a9ae46e6a293f73ba62d5b1df18f.tar.xz
sl0ppij-588cdaa00894a9ae46e6a293f73ba62d5b1df18f.zip
isolate pty thread
Diffstat (limited to 'src/common/errors.rs')
-rw-r--r--src/common/errors.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index c1c6753f..a9156ae6 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -4,6 +4,7 @@
use super::{AppInstruction, ASYNCOPENCALLS, OPENCALLS};
use crate::pty_bus::PtyInstruction;
use crate::screen::ScreenInstruction;
+use serde::{Deserialize, Serialize};
use std::fmt::{Display, Error, Formatter};
@@ -79,7 +80,7 @@ pub fn get_current_ctx() -> ErrorContext {
}
/// A representation of the call stack.
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct ErrorContext {
calls: [ContextType; MAX_THREAD_CALL_STACK],
}
@@ -131,7 +132,7 @@ impl Display for ErrorContext {
/// Complex variants store a variant of a related enum, whose variants can be built from
/// the corresponding Zellij MSPC instruction enum variants ([`ScreenInstruction`],
/// [`PtyInstruction`], [`AppInstruction`], etc).
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Copy, Clone, PartialEq, Serialize, Deserialize)]
pub enum ContextType {
/// A screen-related call.
Screen(ScreenContext),
@@ -141,7 +142,7 @@ pub enum ContextType {
Plugin(PluginContext),
/// An app-related call.
App(AppContext),
- IpcServer,
+ IPCServer, // Fix: Create a separate ServerContext when sessions are introduced
StdinHandler,
AsyncTask,
/// An empty, placeholder call. This should be thought of as representing no call at all.
@@ -174,7 +175,7 @@ impl Display for ContextType {
// FIXME: Just deriving EnumDiscriminants from strum will remove the need for any of this!!!
/// Stack call representations corresponding to the different types of [`ScreenInstruction`]s.
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum ScreenContext {
HandlePtyBytes,
Render,
@@ -267,7 +268,7 @@ impl From<&ScreenInstruction> for ScreenContext {
}
/// Stack call representations corresponding to the different types of [`PtyInstruction`]s.
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum PtyContext {
SpawnTerminal,
SpawnTerminalVertically,
@@ -297,7 +298,7 @@ impl From<&PtyInstruction> for PtyContext {
use crate::wasm_vm::PluginInstruction;
/// Stack call representations corresponding to the different types of [`PluginInstruction`]s.
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum PluginContext {
Load,
Update,
@@ -319,10 +320,13 @@ impl From<&PluginInstruction> for PluginContext {
}
/// Stack call representations corresponding to the different types of [`AppInstruction`]s.
-#[derive(Debug, Clone, Copy, PartialEq)]
+#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum AppContext {
Exit,
Error,
+ ToPty,
+ ToPlugin,
+ ToScreen,
}
impl From<&AppInstruction> for AppContext {
@@ -330,6 +334,9 @@ impl From<&AppInstruction> for AppContext {
match *app_instruction {
AppInstruction::Exit => AppContext::Exit,
AppInstruction::Error(_) => AppContext::Error,
+ AppInstruction::ToPty(_) => AppContext::ToPty,
+ AppInstruction::ToPlugin(_) => AppContext::ToPlugin,
+ AppInstruction::ToScreen(_) => AppContext::ToScreen,
}
}
}