diff --git a/crates/ocs_doc_api/src/executor.rs b/crates/ocs_doc_api/src/executor.rs index b65443279..5f8cbce0f 100644 --- a/crates/ocs_doc_api/src/executor.rs +++ b/crates/ocs_doc_api/src/executor.rs @@ -450,10 +450,7 @@ fn profile_curves( b.profile_curves(profile) } -/// Validate a `Curve2Spec`'s fallible conditions BEFORE mutation (the same rules -/// the host's `curve_spec_to_entity` enforces), so `CreateMany` stays all-or-nothing. -/// Currently: ellipse minor/major ratio must be in (0, 1]. - +/// Validate that an entity exists before performing an operation. fn require_exists(b: &B, id: ObjectId, op: &'static str) -> ApiResult<()> { if b.entity_exists(id) { Ok(()) diff --git a/crates/ocs_plugin_api/src/host.rs b/crates/ocs_plugin_api/src/host.rs index b43bacd8a..dfc2acbf4 100644 --- a/crates/ocs_plugin_api/src/host.rs +++ b/crates/ocs_plugin_api/src/host.rs @@ -746,10 +746,13 @@ mod repl { error: Option, error_type: Option, traceback: Option, - line_number: Option, - column_number: Option, + position: Option<(u32, u32)>, duration_ms: f64, ) -> Self { + let (line_number, column_number) = match position { + Some((l, c)) => (Some(l), Some(c)), + None => (None, None), + }; Self { success, output, diff --git a/crates/ocs_plugin_api/src/ipc/proxy.rs b/crates/ocs_plugin_api/src/ipc/proxy.rs index e7729fcd8..6b5172b08 100644 --- a/crates/ocs_plugin_api/src/ipc/proxy.rs +++ b/crates/ocs_plugin_api/src/ipc/proxy.rs @@ -261,20 +261,13 @@ pub fn run_request_proxy( token: [u8; PROXY_TOKEN_LEN], ) -> std::io::Result<()> { for stream in listener.incoming() { - let mut stream = match stream { - Ok(s) => s, - Err(e) => return Err(e), - }; + let mut stream = stream?; if !verify_token(&mut stream, &token) { continue; } let sender = Arc::clone(&sender); std::thread::spawn(move || { - loop { - let req: PluginRequest = match recv_framed(&mut stream) { - Ok(r) => r, - Err(_) => break, - }; + while let Ok(req) = recv_framed(&mut stream) { let resp = match sender.request(req) { Ok(r) => r, Err(e) => PluginResponse::Error(e.to_string()), diff --git a/crates/ocs_plugin_api/src/process/v4.rs b/crates/ocs_plugin_api/src/process/v4.rs index d2fc60154..05e7dd490 100644 --- a/crates/ocs_plugin_api/src/process/v4.rs +++ b/crates/ocs_plugin_api/src/process/v4.rs @@ -75,10 +75,12 @@ fn request_kind(req: &HostRequest) -> &'static str { } } +type DeferredRequest = (u64, Option, Box); + pub(crate) struct V4Connection { shared: Arc, incoming: Mutex>, - deferred: Mutex, Box)>>, + deferred: Mutex>, call_lock: Mutex<()>, next_id: AtomicU64, reader_handle: Mutex>>, @@ -199,7 +201,7 @@ impl V4Connection { tab_id, payload, }) => { - if tab_id.map_or(true, |request_tab| request_tab == host.tab_id()) { + if tab_id.is_none_or(|request_tab| request_tab == host.tab_id()) { self.respond_to_plugin_request( host, rid, @@ -251,7 +253,7 @@ impl V4Connection { let mut deferred = self.deferred.lock().unwrap_or_else(|e| e.into_inner()); let mut waiting = VecDeque::new(); while let Some((id, tab_id, payload)) = deferred.pop_front() { - if tab_id.map_or(true, |request_tab| request_tab == current_tab_id) { + if tab_id.is_none_or(|request_tab| request_tab == current_tab_id) { ready.push_back((id, payload)); } else { waiting.push_back((id, tab_id, payload)); @@ -271,7 +273,7 @@ impl V4Connection { tab_id, payload, }) => { - if tab_id.map_or(true, |request_tab| request_tab == current_tab_id) { + if tab_id.is_none_or(|request_tab| request_tab == current_tab_id) { self.respond_to_plugin_request( host, id,