diff --git a/Cargo.toml b/Cargo.toml index 7c86dfa..4fa7b4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,14 +31,14 @@ serde = { version = "^1.0", features = ["derive"] } serde_json = "^1.0" bincode = {version="^1.3.1", optional=true} csv = "1.1.3" -pyo3-log = {version="^0.4.0", optional=true} +pyo3-log = {version="^0.6.0", optional=true} [dependencies.websocket] git = "https://github.com/aiarena/rust-websocket" default-features = false [dependencies.pyo3] -version = "^0.14" +version = "^0.16" optional = true features=["auto-initialize"] diff --git a/src/server.rs b/src/server.rs index f9a3b9e..5ad3bdd 100644 --- a/src/server.rs +++ b/src/server.rs @@ -14,10 +14,12 @@ use pyo3::ToPyObject; use serde::{Deserialize, Serialize}; use std::thread; use std::thread::JoinHandle; + pub enum ClientType { Bot, Controller, } + #[cfg_attr(not(feature = "no-pyo3"), derive(Serialize, Deserialize))] pub struct RustServer { ip_addr: String, @@ -86,6 +88,7 @@ impl RustServer { }) } } + #[cfg(not(feature = "no-pyo3"))] #[pyclass(module = "rust_ac")] #[pyo3(text_signature = "(ip_addr)")] @@ -102,7 +105,7 @@ impl PServer { match args.len() { 0 => Self { server: None }, 1 => { - if let Ok(f) = args.get_item(0).extract::<&str>() { + if let Ok(f) = args.get_item(0).and_then(|x| x.extract::<&str>()) { Self { server: Some(RustServer::new(f)), } @@ -144,6 +147,7 @@ impl PServer { Ok(PyBytes::new(py, &serialize(&self.server).unwrap()).to_object(py)) } } + #[cfg(test)] mod tests { use super::*;