Skip to content

Commit

Permalink
Added optional serde dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Jul 7, 2024
1 parent 7cd4126 commit d0f513b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition.workspace = true
authors.workspace = true

[dependencies]
serde = { version = "1.0", features = ["derive"], optional = true }
anyhow.workspace = true
shrinkwraprs.workspace = true
strum.workspace = true
Expand Down
3 changes: 3 additions & 0 deletions crates/net/src/messages/common.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use strum_macros::{AsRefStr, EnumString};
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};

use crate::protocol::*;


#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, AsRefStr, EnumString)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum WitcherNamespace {
#[strum(serialize = "ScriptDebugger")]
ScriptDebugger,
Expand Down
4 changes: 4 additions & 0 deletions crates/net/src/messages/notifications.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::path::PathBuf;

use anyhow::{bail, Context};
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};

use crate::protocol::*;
use super::{Message, WitcherNamespace};
Expand Down Expand Up @@ -38,6 +40,7 @@ impl DisassemblePayload for ListenToNamespaceId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ListenToNamespaceParams {
pub namesp: WitcherNamespace
}
Expand Down Expand Up @@ -122,6 +125,7 @@ impl DisassemblePayload for ScriptsReloadProgressId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ScriptsReloadProgressParams {
Started,
Log {
Expand Down
13 changes: 13 additions & 0 deletions crates/net/src/messages/requests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::path::PathBuf;

use anyhow::Context;
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};

use crate::protocol::*;
use super::{Message, WitcherNamespace};
Expand Down Expand Up @@ -77,6 +79,7 @@ impl DisassemblePayload for ScriptsRootPathResponseId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScriptsRootPathResult {
pub abs_path: PathBuf
}
Expand Down Expand Up @@ -139,6 +142,7 @@ impl DisassemblePayload for ExecuteCommandId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ExecuteCommandParams {
pub cmd: String
}
Expand Down Expand Up @@ -194,6 +198,7 @@ impl DisassemblePayload for ExecuteCommandResponseId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ExecuteCommandResult {
Success {
log_output: Option<Vec<String>>
Expand Down Expand Up @@ -322,11 +327,13 @@ impl DisassemblePayload for ScriptPackagesResponseId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScriptPackagesResult {
pub packages: Vec<ScriptPackageInfo>
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ScriptPackageInfo {
pub package_name: String,
pub abs_scripts_root_path: PathBuf
Expand Down Expand Up @@ -403,6 +410,7 @@ impl DisassemblePayload for OpcodesId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct OpcodesParams {
pub func_name: String,
pub class_name: Option<String>,
Expand Down Expand Up @@ -473,11 +481,13 @@ impl DisassemblePayload for OpcodesResponseId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct OpcodesResult {
pub breakdowns: Vec<OpcodeBreakdown>
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct OpcodeBreakdown {
pub line: i32,
pub opcodes: Vec<String>
Expand Down Expand Up @@ -568,6 +578,7 @@ impl DisassemblePayload for ConfigVarsId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ConfigVarsParams {
pub section_filter: Option<String>,
pub name_filter: Option<String>
Expand Down Expand Up @@ -630,11 +641,13 @@ impl DisassemblePayload for ConfigVarsResponseId {


#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ConfigVarsResult {
pub vars: Vec<ConfigVarInfo>
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ConfigVarInfo {
pub section: String,
pub name: String,
Expand Down

0 comments on commit d0f513b

Please sign in to comment.