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)
|
||||
}
|
||||
|
||||
/// 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: DocApiBackend>(b: &B, id: ObjectId, op: &'static str) -> ApiResult<()> {
|
||||
if b.entity_exists(id) {
|
||||
Ok(())
|
||||
|
||||
@@ -746,10 +746,13 @@ mod repl {
|
||||
error: Option<String>,
|
||||
error_type: Option<String>,
|
||||
traceback: Option<String>,
|
||||
line_number: Option<u32>,
|
||||
column_number: Option<u32>,
|
||||
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,
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -75,10 +75,12 @@ fn request_kind(req: &HostRequest) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
type DeferredRequest = (u64, Option<u64>, Box<PluginRequest>);
|
||||
|
||||
pub(crate) struct V4Connection {
|
||||
shared: Arc<V4HostShared>,
|
||||
incoming: Mutex<mpsc::Receiver<HostIncoming>>,
|
||||
deferred: Mutex<VecDeque<(u64, Option<u64>, Box<PluginRequest>)>>,
|
||||
deferred: Mutex<VecDeque<DeferredRequest>>,
|
||||
call_lock: Mutex<()>,
|
||||
next_id: AtomicU64,
|
||||
reader_handle: Mutex<Option<std::thread::JoinHandle<()>>>,
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user