forked from 1b-agent/opencadstudio-upstream
fix(workspace): resolve clippy warnings in ocs_plugin_api and ocs_doc_api
This commit is contained in:
1 parent
822b0afce5
commit
6e01d464e5
4 files changed
+14
-19
No files matched your search
@@ -450,10 +450,7 @@ fn profile_curves<B: DocApiBackend>(
|
|||||||
b.profile_curves(profile)
|
b.profile_curves(profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate a `Curve2Spec`'s fallible conditions BEFORE mutation (the same rules
|
/// Validate that an entity exists before performing an operation.
|
||||||
/// the host's `curve_spec_to_entity` enforces), so `CreateMany` stays all-or-nothing.
|
|
||||||
/// Currently: ellipse minor/major ratio must be in (0, 1].
|
|
||||||
|
|
||||||
fn require_exists<B: DocApiBackend>(b: &B, id: ObjectId, op: &'static str) -> ApiResult<()> {
|
fn require_exists<B: DocApiBackend>(b: &B, id: ObjectId, op: &'static str) -> ApiResult<()> {
|
||||||
if b.entity_exists(id) {
|
if b.entity_exists(id) {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -746,10 +746,13 @@ mod repl {
|
|||||||
error: Option<String>,
|
error: Option<String>,
|
||||||
error_type: Option<String>,
|
error_type: Option<String>,
|
||||||
traceback: Option<String>,
|
traceback: Option<String>,
|
||||||
line_number: Option<u32>,
|
position: Option<(u32, u32)>,
|
||||||
column_number: Option<u32>,
|
|
||||||
duration_ms: f64,
|
duration_ms: f64,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let (line_number, column_number) = match position {
|
||||||
|
Some((l, c)) => (Some(l), Some(c)),
|
||||||
|
None => (None, None),
|
||||||
|
};
|
||||||
Self {
|
Self {
|
||||||
success,
|
success,
|
||||||
output,
|
output,
|
||||||
|
|||||||
@@ -261,20 +261,13 @@ pub fn run_request_proxy(
|
|||||||
token: [u8; PROXY_TOKEN_LEN],
|
token: [u8; PROXY_TOKEN_LEN],
|
||||||
) -> std::io::Result<()> {
|
) -> std::io::Result<()> {
|
||||||
for stream in listener.incoming() {
|
for stream in listener.incoming() {
|
||||||
let mut stream = match stream {
|
let mut stream = stream?;
|
||||||
Ok(s) => s,
|
|
||||||
Err(e) => return Err(e),
|
|
||||||
};
|
|
||||||
if !verify_token(&mut stream, &token) {
|
if !verify_token(&mut stream, &token) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let sender = Arc::clone(&sender);
|
let sender = Arc::clone(&sender);
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
loop {
|
while let Ok(req) = recv_framed(&mut stream) {
|
||||||
let req: PluginRequest = match recv_framed(&mut stream) {
|
|
||||||
Ok(r) => r,
|
|
||||||
Err(_) => break,
|
|
||||||
};
|
|
||||||
let resp = match sender.request(req) {
|
let resp = match sender.request(req) {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => PluginResponse::Error(e.to_string()),
|
Err(e) => PluginResponse::Error(e.to_string()),
|
||||||
|
|||||||
@@ -75,10 +75,12 @@ fn request_kind(req: &HostRequest) -> &'static str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DeferredRequest = (u64, Option<u64>, Box<PluginRequest>);
|
||||||
|
|
||||||
pub(crate) struct V4Connection {
|
pub(crate) struct V4Connection {
|
||||||
shared: Arc<V4HostShared>,
|
shared: Arc<V4HostShared>,
|
||||||
incoming: Mutex<mpsc::Receiver<HostIncoming>>,
|
incoming: Mutex<mpsc::Receiver<HostIncoming>>,
|
||||||
deferred: Mutex<VecDeque<(u64, Option<u64>, Box<PluginRequest>)>>,
|
deferred: Mutex<VecDeque<DeferredRequest>>,
|
||||||
call_lock: Mutex<()>,
|
call_lock: Mutex<()>,
|
||||||
next_id: AtomicU64,
|
next_id: AtomicU64,
|
||||||
reader_handle: Mutex<Option<std::thread::JoinHandle<()>>>,
|
reader_handle: Mutex<Option<std::thread::JoinHandle<()>>>,
|
||||||
@@ -199,7 +201,7 @@ impl V4Connection {
|
|||||||
tab_id,
|
tab_id,
|
||||||
payload,
|
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(
|
self.respond_to_plugin_request(
|
||||||
host,
|
host,
|
||||||
rid,
|
rid,
|
||||||
@@ -251,7 +253,7 @@ impl V4Connection {
|
|||||||
let mut deferred = self.deferred.lock().unwrap_or_else(|e| e.into_inner());
|
let mut deferred = self.deferred.lock().unwrap_or_else(|e| e.into_inner());
|
||||||
let mut waiting = VecDeque::new();
|
let mut waiting = VecDeque::new();
|
||||||
while let Some((id, tab_id, payload)) = deferred.pop_front() {
|
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));
|
ready.push_back((id, payload));
|
||||||
} else {
|
} else {
|
||||||
waiting.push_back((id, tab_id, payload));
|
waiting.push_back((id, tab_id, payload));
|
||||||
@@ -271,7 +273,7 @@ impl V4Connection {
|
|||||||
tab_id,
|
tab_id,
|
||||||
payload,
|
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(
|
self.respond_to_plugin_request(
|
||||||
host,
|
host,
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in new issue
Block a user